Subject: "Delayed" problem in mfunction/mmacro definition
From: Richard Fateman
Date: Mon, 15 Nov 2004 08:03:16 -0800
I think Albert Reiner gave a pretty good answer, but
the underlying question "How does one do evaluation the
way Mathematica does, using Maxima?" is very suspicious.
1. Mathematica has a rather different model of evaluation
from anything else. I would guess that 99% of Mathematica
users understand only a small part of it. Fortunately,
that is sufficient for most users.
2. Mathematica's evaluation model involves pattern matching,
non-deterministic rules that supposedly prevent infinite
evaluation, but are secret.
3. A detailed examination involving Hold, Evaluate, Delay, etc etc
in Mathematica suggests it is a really bad model.
If you want to use Maxima, I suggest you learn about the evaluation
model in Maxima, NOT by comparison with Mathematica.
4. If you want to learn about programming languages for symbolic
computing, I suggest you learn something that was defined by
computer scientists, not physicists. My favorite language and
book is Lisp, and "ANSI Common Lisp" by Paul Graham.
RJF
Siver Andrey wrote:
> ----- Original Message -----
> From: "Albert Reiner" <areiner at tph>
> To: "Siver Andrey" <siver@sirius.ihep.su>
> Cc: "Maxima-List" <maxima@math.utexas.edu>
> Sent: Sunday, November 14, 2004 5:44 PM
> Subject: Re: [Maxima] "Delayed" problem in mfunction/mmacro definition
>
>
>
>>["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
>>`----
>
>
> Thank you for the example.
>
>
>>>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., ''.
>
>
> What do you mean by ''?
>
> I need to realize Mathematica's:
> *** ex.1 ***
> a=1;
> f := a + 1;
> f
> => 2
> a=2;
> f
> => 3
> *** ex.2 ***
> a=1;
> f = a + 1;
> f
> => 2
> a=2;
> f
> => 2
> ***
> and the same things for functions under MAXIMA. You are right, MAXIMA's ":="
> looks like 'SetDelayed' for functions.
>
> How to see what exactly the expressions does MAXIMA keep for a symbol or a
> function?
>
>
>>HTH,
>>
>>Albert.
>>
>>_______________________________________________
>>Maxima mailing list
>>Maxima@www.math.utexas.edu
>>http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima