Re: print variable name and its value
- To: mathgroup at smc.vnet.net
- Subject: [mg99999] Re: print variable name and its value
- From: mstankus at gmail.com
- Date: Thu, 21 May 2009 00:08:15 -0400 (EDT)
- References: <gv0ius$b8v$1@smc.vnet.net>
On May 20, 2:36 am, "Karsten W." <Karsten.G.Wein... at googlemail.com> wrote: > Hello, > > how can I dump out a variable with its value? The following does not > work: > > myVar1 = 1; > myVar2 = 2; > DumpVars[list_List] := > MapThread[(Print[#1, ": ", #2]) &, {Map[ToString[#] &, > Unevaluated[list]], list}]; > > DumpVar[var_] := Print[ToString[Unevaluated[var]], ":", var]; > > DumpVars[{myVar1, myVar2}] > DumpVar[myVar1] > > Any ideas? > > Kind regards, > Karsten. See http://reference.wolfram.com/mathematica/ref/HoldAll.html