Maxima from Lisp



>>>>> "Nicolas" == Nicolas Neuss <nicolas.neuss at iwr.uni-heidelberg.de> writes:

    Nicolas> Hello,
    Nicolas> I would like to call Maxima from the underlying Lisp for communicating with
    Nicolas> a user.  Therefore, I am interested in Lisp functions for writing data in
    Nicolas> 2d-format to a stream or string, and functions for evaluating a string
    Nicolas> containing a mathematical expression.  E.g., something like
    Nicolas>   (display2d (meval "x+x^2") stream)
    Nicolas> should write
    Nicolas>      2
    Nicolas>     x  + x
    Nicolas> to the stream.

Perhaps this will give you some ideas:

(with-output-to-string (s)
  (let ((*standard-output* s))
    (maxima-display (add '$x (mul '$x '$x))))
  s)
=>
" 2
x  + x
"

Poking around displa.lisp might give some other hints.

If you want to parse "x+x^2" into maxima's internal form, this might
work for you:

(with-input-from-string (s "x+x^2;")
  (mread s))
=>
((DISPLAYINPUT) NIL ((MPLUS) $X ((MEXPT) $X 2)))

The semicolon at the end of the string is important.

Taking cddr of this gives maxima's internal form for x+x^2.

Poking around mdebug.lisp might give some other hints.

Ray