MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: getting the name of a symbol

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15449] Re: getting the name of a symbol
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 18 Jan 1999 04:21:50 -0500
  • References: <77jjc1$2lf@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Andrew Watson wrote in message <77jjc1$2lf at smc.vnet.net>...
>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/
>

Andrew,

Here are some experiments that may  help:

Set up the situation
f[a_] := blah
s=u;


Unevaluated[f[s]]/.HoldPattern[f[x_]]:> SymbolName[Unevaluated[x]]

    "s"

Unevaluated[f[s]]/._[x_]:> SymbolName[Unevaluated[x]]

    "s"

Extract[Unevaluated[f[s]],{1},Function[x,
SymbolName[Unevaluated[x]],HoldAll]]

    "s"

We can get get functions from these to do the trick: for example

Function[y, Unevaluated[y]/._[x_]:> SymbolName[Unevaluated[x]],
HoldAll][f[s]]

    "s"


Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565




  • Prev by Date: Animated 3D problem: all frames show up.
  • Next by Date: ? scatterplots with differently sized labels and dots ?
  • Previous by thread: Re: getting the name of a symbol
  • Next by thread: Re: getting the name of a symbol