From: Michel T. <ta...@lp...> - 2022-07-09 17:28:59
|
Another one, using a macro: (%i1) foo(a, b, c, d, e)::= bar(bar(bar(bar(a,b),c),d),e); (%o1) foo(a, b, c, d, e) ::= bar(bar(bar(bar(a, b), c), d), e) (%i2) foo(a,2,4,1,3); (%o2) bar(bar(bar(bar(a, 2), 4), 1), 3) (%i3) bar(x,y):=x*y+x+y; (%o3) bar(x, y) := x y + x + y (%i4) foo(a,2,4,1,3); (%o4) 3 (8 (3 a + 2) + 6 a + 13) + 8 (3 a + 2) + 6 a + 16 (%i5) expand(%); (%o5) 120 a + 119 Hope this is correct. Le 09/07/2022 à 18:59, Raymond Toy a écrit : > > > On Sat, Jul 9, 2022 at 8:55 AM Eduardo Ochs <edu...@gm...> wrote: > > Hi list, > > how do I define a function "foo" that does this? > > foo(a, 2, 4, 1, 3) > > returns the result of: > > bar(bar(bar(bar(a, 2), 4), 1), 3) > > > Maybe this: > > foo([x]) := xreduce(bar, x); > > foo(a,2,4,1,3); > bar(bar(bar(bar(a, 2), 4), 1), 3) > > > Thanks in advance! > Eduardo Ochs > http://angg.twu.net/eev-maxima.html > > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > > > > -- > Ray > > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss -- Michel Talon |