Re: Extracting the name of a variable

*To*: mathgroup at smc.vnet.net*Subject*: [mg26918] Re: [mg26883] Extracting the name of a variable*From*: Ken Levasseur <Kenneth_Levasseur at uml.edu>*Date*: Fri, 26 Jan 2001 23:29:57 -0500 (EST)*References*: <200101260627.BAA18734@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Mike: This seems to work: In[1]:= z = 3 Out[1]= 3 In[2]:= Attributes[nameExtract] = {HoldAll} Out[2]= {HoldAll} In[3]:= nameExtract[a_] := HoldForm[a] // ToString In[4]:= nameExtract[z] // FullForm Out[4]//FullForm= "z" Ken Levasseur Math Sci UMass Lowell Mike Yukish wrote: > Hello, > > I'd like to make a function that extracts the name of a variable and > makes a string. So the function would do: > > In: z = 4 > > In: nameExtract[z] > > Out: "z" > > It appears to not be so simple, since once you assign z a value, the > function SymbolName[z] returns an error. what's the trick? > > I want to do this so I can make a function takes z as an argument, and > generates a name:value pair "z=4"

**References**:**Extracting the name of a variable***From:*Mike Yukish <may106@psu.edu>