get name of variable as string in function?



or you could also use something like this:

(%i1) mprint(z) := if listp(z) then map(mprint, z) else printf(true, "~a 
= ~a~%", z, ev(z))$
(%i2) a: 2$
(%i3) [b,c]: [%pi, 2/5]$

(%4) mprint('a);
a = 2
(%o4)                        false
(%i5) mprint(['a,'b,'c]);
a = 2
b = %pi
c = 2/5
(%o5)                [false, false, false]


On 02/02/2012 10:13 PM, Stavros Macrakis wrote:
> I suggest you keep things simple and modular:
>
> /* The worker function */
> mprintx(name,val) := print(sconcat("  ",name," = "),val)$
>
> mprint('a,a)$
>
> /* Print 1 variable */
> mprint(zz23) := mprintx(zz23,ev(zz23))$
>
> mprint('a)$
>
> /* Print many variables in a list */
> mprintl(ll23) := map(mprintx,ll23,map(ev,ll23))$
>
> mprintl('[a,b])$
>
> /* Print many variables as multiple arguments */
> mprintll([mm23]) ::= subst(mm23,'mm23,'(mprintl('mm23)))$
>
> mprintll(a,b)$
>
>              -s
>
> mprintll(a,b);
>
>
> On Thu, Feb 2, 2012 at 16:36, Edwin Woollett <woollett at charter.net 
> <mailto:woollett at charter.net>> wrote:
>
>
>     On Feb. 2, 2012,  Stavros Macrakis wrote:
>     ---------------------
>
>         mprint(zz) := print(sconcat(zz," = ",ev(zz)))$ and then
>         mprint('a).
>
>     ------------------------
>     This works. Now I want to define mdisplay(a)
>     or mdisplay(a,b), etc to apply this def. to each
>     arg in succession. But my tries so far fail:
>     ---------------------------------------------------
>     (%i1) [a,b] : [2,3];
>     (%o1) [2,3]
>
>     (%i2) mprint(zz234) := print(sconcat("  ",zz234," = "),ev(zz234))$
>
>     (%i3) mprint('a);
>
>      a =  2 (%o3) 2
>
>     (%i4) map('mprint,'[a,b]);
>      a =  2  b =  3 (%o4) [2,3]
>
>     (%i5) mdisplay([vv]) := map('mprint,'vv)$
>
>     (%i6) mdisplay(a,b);
>     map: improper argument: vv
>     #0: mdisplay(vv=[2,3])
>     -- an error. To debug this try: debugmode(true);
>
>     (%i7) mdisplay([vv]) := (print(vv),map('mprint,'vv))$
>
>     (%i8) mdisplay(a,b);
>     [2,3] map: improper argument: vv
>     #0: mdisplay(vv=[2,3])
>     -- an error. To debug this try: debugmode(true);
>
>     -----------------------------------
>     Ted
>
>
>
>
>
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima