Re: getting the name of a symbol
- To: mathgroup at smc.vnet.net
- Subject: [mg15453] Re: [mg15412] getting the name of a symbol
- From: "Richard W. Singerman" <rws at helix.nih.gov>
- Date: Mon, 18 Jan 1999 04:21:54 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Andrew,
Pass the string to the function, ie put quotes around your symbol, and
then evaluate the string in your function.
Example:
f[y_] := Module[{valueY, stringY},
valueY = ToExpression[y];
stringY = y;
Print[stringY];
Print[valueY];
]
x =5
f["x"]
f prints
x
5
--Richard
ps. I see you're at NASA Ames. I'm currently working with Stanford
Telecom at NASA Goddard.
What are you working on?
Richard Singerman, Ph.D.
BioQuest
1761 R Street, NW Suite 2
Washington, DC 20009
Phone: (202) 986-5866
email: rws at alum.mit.edu
On Wed, 13 Jan 1999, Andrew Watson wrote:
> Dear Matherati,
>
> I have a problem for which there must be a simple solution.
>
> Within a function
>
> f[a_] := blah blah blah
>
> I want to make use of the name of the symbol supplied as input to the
> function.
>
> For example, if called as
>
> f[qxyz]
>
> I want to get the string "qxyz". I have looked at HoldForm and
> SymbolName but nothing yet discovered seems to do the trick.
>
> Regards,
>
>
> Andrew B. Watson
> MS 262-2
> NASA Ames Research Center
> Moffett Field, CA 94035-1000
> (650) 604-5419 (650) 604-0255 fax
> abwatson at mail.arc.nasa.gov http://vision.arc.nasa.gov/
>