Re: Variable question
- To: mathgroup at smc.vnet.net
- Subject: [mg92506] Re: Variable question
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 2 Oct 2008 04:34:48 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <gc0tkn$9ci$1@smc.vnet.net>
Johney at giganews.com wrote: > I have the following test code > > c = 3 > var = "c" > v = StringTake[var, {1}] > v > > > v is showing up as c but I want it to show up as 3. Is there a way to do this? What you are looking for is the built-in function *ToExpression*, which takes a string of characters as argument, transforms it into a regular Mathematica expression that is evaluated, then the result of the evaluation is returned. In[1]:= c = 3 var = "c" v = ToExpression[var] v Out[1]= 3 Out[2]= "c" Out[3]= 3 Out[4]= 3 Regards, -- Jean-Marc