MathGroup Archive 2008

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

Search the Archive

Re: Variable question


StringTake[var, {1}] returns a string consisting of the first character of
var, i.e. "c". You should use


ToExpression[StringTake[var, {1}]]


In[5]:= c = 3
var = "c"
v = ToExpression[StringTake[var, {1}]]
Out[5]= 3
Out[6]= "c"
Out[7]= 3


Adriano Pascoletti

2008/10/2 <Johney at giganews.com>

> 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?
>
> Thanks
>
>
>


  • Prev by Date: Re: Variable question
  • Next by Date: Re: command line options: -initfile vs -run
  • Previous by thread: Variable question
  • Next by thread: Re: Variable question