From: Tamas Papp <tkpapp at gmail.com>
Date: Fri, 19 Jul 2013 11:43:02 +0200
Hi,
Is there a quick & easy way to translate results of calculations to
Common Lisp (or any Lisp) sexps? Eg a+b*c would become (+ a (* b c)),
etc. I need this because I would like to use analytical results,
calculated with Maxima, in a CL program, and I don't want to transcribe
it manually if that can be avoided.
Tamas, you could certainly do all this inside a Maxima image.
E.g.
MAXIMA> #$ f(x,y,z) := block([], mode_declare([x,y,z],flonum), x*(y+z)); $
((MDEFINE SIMP) (($F) $X $Y $Z)
((MPROG) ((MLIST)) (($MODEDECLARE) ((MLIST) $X $Y $Z) $FLONUM)
((MTIMES) $X ((MPLUS) $Y $Z))))
MAXIMA> (mfuncall '$compile '$f)
((MLIST SIMP) $F)
MAXIMA> ($f 4 5 6)
; Evaluation aborted on #<TYPE-ERROR expected-type: DOUBLE-FLOAT datum: 4>.
MAXIMA> ($f 4.0 5.0 6.0)
44.0
You can also use the package system to selectively export your
functions.
Leo