question about list utilities



On 4/12/07, sen1 at math.msu.edu <sen1 at math.msu.edu> wrote:
>
>   for some reason, is it equivalent in terms of speed, to do
>
> return(last(sort(list))) or
>
> l1: sort(list),
> return(last(l1))
>

Not surprising. An assignment and a variable fetch aren't very expensive.

It's I suppose more of an aesthetic preference to use

          f(x):= last(sort(x))

rather than

          f(x):=block([l1],
                              l1: sort(list),
                              last(l1) )                    /* Last
expression of a block is returned as value of block */

or

          f(x):=block([l1],
                              l1: sort(list),
                              return(last(l1) ))          /* return not
really needed */

For those of us with a Lisp background, the second two seem terribly stilted
and wordy, but I suppose those with a Fortran background would find the
first version unfamiliar.

             -s


               -s