Subject: "Delayed" problem in mfunction/mmacro definition
From: Albert Reiner
Date: 14 Nov 2004 15:44:11 +0100
["Siver Andrey" <siver@sirius.ihep.su>, Sun, 14 Nov 2004 13:07:51 +0300]:
> (%i3) F3(x)::='(x);
> (%o3) F3(x) ::= 'x
> (%i4) F3(y);
> (%o4) x
> (should be 'y' instead)
,----
| (%i1) F5(x) ::= buildq([x], 'x);
|
| (%o1) F5(x) ::= BUILDQ([x], 'x)
| (%i2) F5(y);
|
| (%o2) y
`----
> This is important question for definition of Mathematica ":="
> (SetDelayed) function for MAXIMA (I thought that 'SetDelayed' could
> be interpreted as (MDEFINE) (or (MDEFMACRO)) but with second
> argument (MQUOTE)ed and with first argument 'a' --> (MEVAL a) at the
> evaluation time BUT found it's not a case).
If you only want to do something like
f[x_] := Sin[x]
so that
f[2] --> Sin[2]
f[1+1] --> Sin[2]
, you can simply use Maxima's ":=" which already does the right thing;
if you want the right hand side to be evaluated (as with Set) you have
to explicitly ask for that with, e.g., ''.
HTH,
Albert.