Depending on what you want to do with it, you may find
it possible, instead of
lisp(x)
to do
?print(x)
which prints, in lisp syntax, the expression x.
In this particular case you get
((MEXPT SIMP) ((MPLUS SIMP) |$a| |$b|) 2)
which is close to what you wrote.
What you need is a program that
changes ((MEXPT ...) ....) to (expt ...) etc. And also
strip the dollarsigns off. Exists as stripdollar.. e.g.
?print (fullmap (?stripdollar,d1)); removes them.
There are no canonical lisp versions of many of the
operations in macsyma, and even the ones that you
think you know about, e.g. + instead of (mplus ...)
do different things. Like + doesn't know what to
do with non-numbers.
If you want to translate the function f(a,b):=(a+b)^2
to lisp with Macsyma semantics, do translate(f). The
lisp "text" part is somewhere on the property list
of the lisp atom |$f|.
You can also compile(f) into machine language.
RJF
Liam M. Healy wrote:
> Can I generate Lisp expressions from Maxima definitions? I can
> generate Fortran with fortran(foo); but there doesn't seem to be a
> lisp(foo).
>
> x : (a + b)^2;
>
> 2
> (D7) (b + a)
> (C8) fortran(x);
>
> (b+a)**2
> (D8) DONE
>
>
> Dreaming:
> (C9) lisp(x);
> (expt (+ a b) 2)
> (D9) DONE DREAMING
>
>
> seems a bit ironic if this function or equivalent doesn't exist.
>
>
> (side point: to_lisp() exits Maxima; is that supposed to happen?)
>
> Liam
>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima