Subject: get name of variable as string in function?
From: Edwin Woollett
Date: Thu, 2 Feb 2012 13:36:02 -0800
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