From: Eduardo O. <edu...@gm...> - 2022-07-10 01:27:52
|
On Sat, 9 Jul 2022 at 22:15, Stavros Macrakis <mac...@al...> wrote: > > Use a=b to test structural equality. > > equal(a,b) is for mathematical equality, and is unknown (not false) in the absence of assertions (assume) about a and b. Perfect! Many thanks! =) Here is a transcript: (%i1) foo1 : lambda([o, action], if action = op then op(o) elseif action = args then args(o) else args(o)[action]); (%o1) lambda([o, action], if action = op then op(o) elseif action = args then args(o) else args(o) ) action (%i2) foo(a, [b]) := xreduce(foo1, b, a); (%o2) foo(a, [b]) := xreduce(foo1, b, a) (%i3) ex1 : a+b*c; (%o3) b c + a (%i4) foo(ex1); (%o4) b c + a (%i5) foo(ex1, op); (%o5) + (%i6) foo(ex1, args); (%o6) [b c, a] (%i7) foo(ex1, 1); (%o7) b c (%i8) foo(ex1, 1, op); (%o8) * (%i9) foo(ex1, 1, args); (%o9) [b, c] (%i10) foo(ex1, 1, 1); (%o10) b (%i11) foo(ex1, 1, 2); (%o11) c (%i12) foo(ex1, 2); (%o12) a Cheers =), Eduardo Ochs http://angg.twu.net/eev-maxima.html |