Subject: Different max behavior from commercial product.
From: Barton Willis
Date: Sun, 28 Aug 2005 20:07:57 -0500
> Richard Fateman wrote:
>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
Your dominate function is almost the same as the nset lreduce function.
(%i1) load("nset");
(%o1) c:/maxima/nset-1.2.03/nset.lisp
(%i2) rreduce(f,[1,2,3,4]);
(%o2) f(1,f(2,f(3,4)))
(%i3) rreduce(f,[1,2,3,4],x);
(%o3) f(1,f(2,f(3,f(4,x))))
(%i4) lreduce(f,[1,2,3,4],x);
(%o4) f(f(f(f(x,1),2),3),4)
(%i5) tree_reduce(f,[1,2,3,4],x);
(%o5) f(f(f(x,1),f(2,3)),4)
(%i6) tree_reduce(f,[1,2,3,4]);
(%o6) f(f(1,2),f(3,4))
(%i2) dominate(f,[1,2,3,4],x);
(%o2) f(4,f(3,f(2,f(1,x))))
Provided f(x,y) = f(y,x), I think lreduce and dominate are the same.
Barton