Subject: Using lisp displa to view local variables
From: Stavros Macrakis
Date: Tue, 26 Jul 2011 15:25:49 -0400
That all looks correct to me. If you want something like (ldisplay x y z)
to print x=3, y=3, etc., then ***ldisplay*** needs to be a macro.
-s
On Tue, Jul 26, 2011 at 15:15, Edwin Woollett <woollett at charter.net> wrote:
> On July 26, 2011, Stavros Macrakis wrote:
> **************************
>
> You need to make $display_value into a Lisp macro, e.g.
>
> (defmacro $display_value (x)
> `(displa (list '(mtext) ',x " = " ,x)))
>
> Maxima does allow Lisp macros in Maxima
> expressions, so you can call this from either
> Maxima or Lisp code.
> *******************************************
> Thanks for the approach, which I get to work with
> a direct call, but not when mapping on a list:
> ------------------------------**---------------------
> MAXIMA> (defmacro $display_value (x) `(displa (list '(mtext) ',x " = "
> ,x)))
>
> $DISPLAY_VALUE
>
> MAXIMA> (defun f1 ()
>
> (let ((a1 'aa) (s1 "my string") (l1 '(a b c)))
> (mtell "local")
> ($display_value s1)
> (mtell "bye")))
>
> F1
> MAXIMA> (f1)
>
> local
> s1 = my string
> bye
> NIL
>
> MAXIMA> (defun ldisplay (&rest xx)
> (mapcar #'(lambda (s) ($display_value s)) xx))
>
> LDISPLAY
>
> MAXIMA> (defun f1 ()
>
> (let ((a1 'aa) (s1 "my string") (l1 '(a b c)))
> (mtell "local")
> (ldisplay s1 l1 a1)
> (mtell "bye")))
>
> F1
>
> MAXIMA> (f1)
>
> local
> s = my string
> s = (a, b, c)
> s = aa
> bye
> NIL
>
> MAXIMA> (defun f1 ()
>
> (let ((a1 'aa) (s1 "my string") (l1 '(a b c)))
> (mtell "local")
> (ldisplay 's1 'l1 'a1)
> (mtell "bye")))
>
> F1
>
> MAXIMA> (f1)
>
> local
> s = s1
> s = l1
> s = a1
> bye
> NIL
> ------------------------------**-------
> Ted Woollett
>
>