Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Variable question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92511] Re: Variable question
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Thu, 2 Oct 2008 04:35:48 -0400 (EDT)
  • 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?
> 
> Thanks

you need to convert the string "c" to the symbol c, which can be done
like this:

c = 3
var = "c"
v = Symbol[StringTake[var, {1}]]
v

or this:

c = 3
var = "c"
v = ToExpression[StringTake[var, {1}]]
v

hth,

albert


  • Prev by Date: RE: Avoiding Null output marker from a function
  • Next by Date: Re: Simplifying Bessel Functions
  • Previous by thread: Re: Variable question
  • Next by thread: Re: Variable question