On Wed, 21 Apr 2010, Mikhail Khokhlov wrote:
< Hi,
<
< Is it a bug, or am I doing something wrong?
<
< (%i1) myfun(a) := ev(a);
< (%o1) myfun(a) := ev(a)
< (%i2) myfun(a+b);
< (%o2) 2 b + a
<
< Obviously, "a" evaluates to "a+b" twice in this example. Why does this happen?
< Function parameter should evaluate to its value only once, regardless of what
< its name is.
This is documented behaviour. Your example makes it seem strange, but
here is a more pedestrian example that shows what's going on. It is
explained in
? ev
----
(%i2) block([x:y,y:z],ev(x,noeval));
(%o2) y
(%i3) block([x:y,y:z],ev(x));
(%o3) z
(%i4) trace(ev);
(%o4) [ev]
(%i5) block([x:y,y:z],ev(x,noeval));
1 Enter ev [ev(x,noeval)]
1 Exit ev y
(%o5) y
(%i6) block([x:y,y:z],ev(x));
1 Enter ev [ev(x)]
1 Exit ev z
(%o6) z
Leo
<
< Best regards,
< Mikhail Khokhlov
< _______________________________________________
< Maxima mailing list
< Maxima at math.utexas.edu
< http://www.math.utexas.edu/mailman/listinfo/maxima
<
<
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.