Am Samstag, den 23.07.2011, 12:05 -0700 schrieb Edwin Woollett:
> On July 22, 2011, Barton Willis wrote:
> ****************************
> Use mfuncall to call a defmspec function from CL
>
> (%i2) :lisp(mfuncall '$display 'x 'y 42)
> x=x
> y=y
> 42=42
> $DONE
> ************************
> Thanks for the suggestion.
> Your method works for a lisp string but
> not for a lisp list, as shown below:
> ---------------------------
> Maxima 5.24.0
> using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
>
> (%i1) display2d:false$
> (%i2) to_lisp();
> Type (to-maxima) to restart, ($quit) to quit Maxima.
>
> MAXIMA> (setq s1 "My string")
>
> "My string"
> MAXIMA> (setq l1 '(1 2 3))
>
> (1 2 3)
> MAXIMA> (mfuncall '$display 's1)
> ?s1 = "My string"
>
> $DONE
> MAXIMA> (mfuncall '$display 'l1)
>
> Maxima encountered a Lisp error:
>
> Error in EVAL [or a callee]: Caught fatal error [memory may be damaged]
>
> Automatically continuing.
> To reenable the Lisp debugger set *debugger-hook* to nil.
>
> MAXIMA>
> ------------------------------------
Here is a further suggestion:
MAXIMA> (defun $display_value (x) (displa `((mequal) ,x ,(eval x))))
$DISPLAY_VALUE
MAXIMA> (setq expr '((mplus) $a $b $c))
((MPLUS) $A $B $C)
MAXIMA> ($display_value 'expr)
expr = a + b + c
NIL
MAXIMA> (setq l1 '(1 2 3))
(1 2 3)
MAXIMA> ($display_value 'l1)
l1 = (1, 2, 3)
NIL
There are a lot of more possibilities, e.g. an example with a
mtext-expression:
MAXIMA> (defun $display_value (x)
(displa `((mtext) ,x " = " ,(eval x))))
$DISPLAY_VALUE
MAXIMA> (display_value 'expr)
expr = a + b + c
NIL
MAXIMA> (display_value 'l1)
l1 = (1, 2, 3)
NIL
Dieter Kaiser