MathGroup Archive 2001

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

Search the Archive

Re: Extracting the name of a variable


"Ersek, Ted R" wrote:

> Mike Yukish asked how one can take a variable which has a value assigned and
> convert it to a string without letting it evaluate.
>
> I provide the solution in the section for (ToString) on my web site.  The
> URL is
> http://www.verbeia.com/mathematica/tips/Tricks.html

Many thanks to all who replied. I posed my problem as a subpart of a more
complex problem, which still defeats me. I had hoped to Map[ ] the function
extractName over a list, and extract the names of all the variables in the list.
Ted has identified its difficulties, which I offer up here.

Problem: Create a function that takes a list of variables, and extracts the
symbol name of each. This is an added level over the initial problem.

q=4
z=5

list1={q,z,w}

extractNamesFromList[list1]

out[]:=

{"q","z","w"}

Ted Ersek and Bob Hanlon have both shown me how to create a function that will
work with

extractNamesFromList[{q,z,w}]

out[]:=
{"q","z","w"}


but  extractNamesFromList[list1]
out[]:=
"list1"

So passing a predeclared list is a different story, and Ted pointed that out. I
think I can live with the restriction, though.





  • Prev by Date: Re: Multiply 2 Lists together in a certain way
  • Next by Date: Re: Multiply 2 Lists together in a certain way
  • Previous by thread: Re: Extracting the name of a variable
  • Next by thread: Re: Re: Extracting the name of a variable