Using lisp displa to view local variables



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