Lisp code from maxima calculation



Hi,

I hope you don't mind if I ask another one of what must be pretty
trivial questions: being new to maxima, I always suspect I miss the
obvious, or that a solution may already exist.

My current conundrum to poner is about finding the most convenient way
to massage a symbolic result from maxima into code to be run in a Lisp
program.

An example may be clearer:  Suppose I have this trivial maxima code

    foo(x) := cos(2*x)+3 $

so that

    foo(x) ==> COS(2*x)+3

from maxima, and

    (mfuncall '$|foo| 'x) ==>
        ((MPLUS SIMP) 3 ((%COS SIMP) ((MTIMES SIMP) 2 X)))

Eventually, I will want to make use of the result of foo in CL
through, e.g., macros expanding to

    (labels ((foo (x) (declare ...) (+ 3d0 (cos (* 2d0 x))))) ...)
    (defun foo (x) (declare ...) (+ 3d0 (cos (* 2d0 x))))

or through

    (compile nil `(lambda (x) ,(some-processing (mfuncall '$|foo| 'x))))

at run time.

The crux is, of course, that some-processing: I have looked at the
documentation, but TRANSLATE and TRANSLATE_FILE are all I found that
seemed related but actually do something different.  So currently it
seems to me that the right thing is to walk down the list structure
returned by maxima and do the obvious transformations.  My questions:

- Am I missing something?

- Is there some documentation of the list structure visible from Lisp?

- Does someone already have some code to do so?  This seems a natural
  thing to want to do, after all.

Thanks in advance,

Albert.