macros (or similar) in Maxima



Hi, Tamas.

May be it will be usefull for you. I made some changes in maxima to
use it in common lisp projects. This fork fully compatibly with
original maxima, and I keep sources up-to-date to original repository.

You can download sources here:
https://github.com/filonenko-mikhail/embeddable-maxima/tarball/quicklisp

Usage:

;;;;; COMMON LISP REPL
(push "/path/to/sources/embaddalbe-maxima" asdf:*central-registry*)
(ql:quickload :embeddable-maxima)

;;;; run maxima repl for tests for your cl implementation
(cl-user::run)
;;;; MAXIMA REPL
;;;; run tests
  runt_testsuite();
  quit();

;;;;; COMMON LISP REPL
;;; Maxima does not export symbols, we go to it package.
(in-package :maxima)
;;;; Make AST from string. Do NOT forget semicolon at the end of string.
(macsyma-read-string "x:1+y;")
-> ((MSETQ) $X ((MPLUS) 1 $Y))
;;;; Evaluate returned AST
(mfuncall '$ev *)
-> ((MPLUS SIMP) 1 $Y)
;;;; Convert returned result AST to maxima string
(displa *)



2012/4/3 Tamas Papp <tkpapp at gmail.com>:
> Hi,
>
> Can I achieve the effect of
>
> texput(W10,"W_{10}")$
> texput(W11,"W_{11}")$
> texput(W20,"W_{20}")$
> texput(W21,"W_{21}")$
> texput(W22,"W_{22}")$
>
> texput(w10,"w_{10}")$
> texput(w11,"w_{11}")$
> texput(w20,"w_{20}")$
> texput(w21,"w_{21}")$
> texput(w22,"w_{22}")$
>
> texput(g10,"g_{10}")$
> texput(g11,"g_{11}")$
> texput(g20,"g_{20}")$
> texput(g21,"g_{21}")$
> texput(g22,"g_{22}")$
>
> with some kind of macro in Maxima?
>
> This is how I attempted to do it (not with a macro, but by calling texput directly):
>
> :lisp (flet ((texputall (prefix &key (latex prefix) (subscripts '("10" "11" "20" "21" "22"))) (loop for subscript in subscripts do (mfuncall '$texput (make-symbol (format nil "$~A~A" prefix subscript)) (format nil "~A_{~A}" latex subscript))))) (loop for s in '("w" "W" "g") do (texputall s)))
>
> but it didn't work (Lisp error: (void-function mfuncall)).
>
> Generally, what's the best way to write (debug, etc) more complex CL
> constructs used in Maxima? ?I am using Emacs and I am familiar with
> SLIME, so it would be great if I could use it to write CL for Maxima
> somehow. ?It would be nice to get indentation in the code I write,
> also not being forced to put in on one line for :lisp.
>
> Best,
>
> Tamas
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima



-- 
With best regards, Michael Filonenko