Code in array1.spad can never be executed

19 views
Skip to first unread message

Hill Strong

unread,
Feb 4, 2024, 7:46:31 AM2/4/24
to fricas...@googlegroups.com
In the array1.spad file the following is defined

    shrink(r, i) ==
       r.logLen := r.logLen - i
       negative?(n := r.logLen) => error "internal bug in flexible array"
       2*n+2 > r.physLen => r
       not shrinkable? => r
       if n < r.logLen then error "cannot shrink flexible array to indicated size"
       n = 0 => empty()
       r.physLen := n
       y := newa(n::N, a := r.f)
       for k in 0 .. n-1 repeat y.k := a.k
       r.f := y
       r

The line starting with

if n < r.logLen

can never be executed as the previous definition for n has already set this value to r.logLen.

I can, if anyone is interested, create a pull request to remove this specific line from the definition.

Hill Strong

Grégory Vanuxem

unread,
Feb 4, 2024, 12:20:53 PM2/4/24
to fricas...@googlegroups.com
Hello,

I am on a smartphone with family but the code seems cryptic to me. What is shrinkable? ? A variable holding a Boolean? Another thing? Usually, with a question mark, this should be a boolean function. But there is no argument…
Cryptic also…


--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/CAEnaMTEMYW67h3%3DkLQnNJ%2BQ__hnyw4xUH2RKcvGSNWccQ0hEVg%40mail.gmail.com.

Ralf Hemmecke

unread,
Feb 4, 2024, 12:42:22 PM2/4/24
to fricas...@googlegroups.com
On 2/4/24 18:20, Grégory Vanuxem wrote:
> Hello,
>
> I am on a smartphone with family but the code seems cryptic to me.
> What is shrinkable?
> ?

https://github.com/fricas/fricas/blob/master/src/algebra/array1.spad#L138

https://github.com/fricas/fricas/blob/master/src/algebra/array1.spad#L157

Ralf

Grégory Vanuxem

unread,
Feb 4, 2024, 1:33:37 PM2/4/24
to fricas...@googlegroups.com
Ralf.

Thanks for the links. As a courtesy to other I didn’t took the time to read the code but yes now,  it’s a boolean variable. Personally I would not have chosen to use the question mark here but after all, everyone code in his own way. Surprised so.

Regards,

- Greg

--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.

Waldek Hebisch

unread,
Feb 4, 2024, 7:20:02 PM2/4/24
to fricas...@googlegroups.com
Thanks, for 1 line change it is simpler for me to just make the change.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages