evaluate Maxima string from lisp command line...



"Stavros Macrakis" <stavros.macrakis@verizon.net> writes:

> In other words, you want to parse a string as Macsyma language.  The
> macsyma-read-string function is supposed to do this, but doesn't work in
> 5.9.0/GCL.

Because it needs a string with a fill-pointer.

(defun add-fill-pointer-to (array)
  (if (array-has-fill-pointer-p array)
      array
      (make-array (length array)
		  :element-type (array-element-type array)
		  :displaced-to array
		  :fill-pointer t)))

(macsyma-read-string (add-fill-pointer-to "diff(x^2,x)"))
(($DIFF) ((MEXPT) |$x| 2) |$x|)

Annoyingly, the input line label is sent to the output stream.

But... why don't you want to use the #$ reader macro, which is
described somewhere in the manual.

MAXIMA> '#$diff(x^2,x)$
(MEVAL* '(($DIFF) ((MEXPT) |$x| 2) |$x|))
MAXIMA> (eval *)
((MTIMES SIMP) 2 |$x|)
MAXIMA> (displa *)
2 x
NIL

Wolfgang