Different max behavior from commercial product.



An nset solution:

(%i1) listmax(s) := if listp(s) or setp(s) then tree_reduce('max, s, 'minf)
                         else
                         error("The argument to 'listmax' must be a list or
                         a set")$

(%i2) listmax([]);
(%o2) minf

Unlike apply('max, list), the listmax function can handle long lists.

(%i3) listmax(makelist(i,i,1,10000));
(%o3) 10000

(%i4) apply('max, makelist(i,i,1,10000));
Maxima encountered a Lisp error: ...

Barton