macros (or similar) in Maxima



Tamas,

I think Ray Toy's answer solves your problem.

But I'm curious to understand why you thought you needed to use Maxima
macros rather than regular Maxima functions to solve this problem.  Also
curious to understand why you went directly to Lisp rather than code in the
Maxima language.

Perhaps some other computer algebra system you've used wasn't fully
programmable?  or had macro semantics instead of function semantics?

              -s

On Tue, Apr 3, 2012 at 01:48, Tamas Papp <tkpapp at gmail.com> wrote:

> 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
>