Subject: Different max behavior from commercial product.
From: Richard Fateman
Date: Sun, 28 Aug 2005 17:28:25 -0700
Barton Willis wrote:
> 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
>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
I dunno about nset... but
dominate(fun,list,default):= if emptyp(list) then default else
dominate(fun,rest(list),fun(first(list),default));
then you can do
listmax(list):= dominate(max,list,minf);
for example.
I guess dominate is the same as tree_reduce, huh?
RJF