MathGroup Archive 2006

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

Search the Archive

Re: returning a variable's name, rather than the variable's contents

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68435] Re: returning a variable's name, rather than the variable's contents
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 5 Aug 2006 03:46:30 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <eauvns$17c$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Michael Stern wrote:
> There must be a simple way to do this but it eludes me. Take for example the
> following: 
> 
> In[2]:= a=1;b=2;c=3;
> 
> In[3]:= Max[a,b,c]
> 
> Out[3]= 3
> 
> What would I do if I wanted Out[3] to equal "c" ?

What about the following trick?

In[1]:=
vars = {a, b, c};
varNames = ToString /@ vars;
values = {1, 2, 3};
vars = values;
First[Extract[varNames, Position[vars, Max[vars]]]]

Out[5]=
"c"

HTH,
Jean-Marc


  • Prev by Date: Re: returning a variable's name, rather than the variable's contents
  • Next by Date: Re: How to treat this false singular point?
  • Previous by thread: Re: returning a variable's name, rather than the variable's contents
  • Next by thread: RE: returning a variable's name, rather than the variable's contents