Finding the maximum in a list



----Neilen Marais  wrote: -----

> Some people also suggested the use of apply vs.
> lreduce. What is the real difference between the two?
> I'm a little confused.

If you use the apply('max, l) on a long enough list, you'll
get a lisp error. This is a limitation of common lisp
(and the way that apply is written, I suppose). If you use
lreduce (or lmax or lmin) you  shouldn't have a problem with
long lists:

(%i1) l : makelist(a+i,i,0,100)$
(%i2) apply('max,l);
Maxima encountered a Lisp error:
 Error in MACSYMA-TOP-LEVEL [or a callee]: MACSYMA-TOP-LEVEL [or a callee]
 requires less than one hundred one arguments.

(%i3) lreduce('max,l);
(%o3) a+100
Barton