MathGroup Archive 2005

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

Search the Archive

Re: Newbie Programming question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53445] Re: [mg53436] Newbie Programming question
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 12 Jan 2005 03:41:16 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

var[i_Integer, val_] := ToExpression["var"<>ToString[i]<>"="<>ToString[val]];

var[17,23];

var17

23


Bob Hanlon

> 
> From: Kerry Kim <kjkim at u.washington.edu>
To: mathgroup at smc.vnet.net
> Date: 2005/01/11 Tue AM 01:32:02 EST
> To: mathgroup at smc.vnet.net
> Subject: [mg53445] [mg53436] Newbie Programming question
> 
> Hello,
> 
> Is there any way in Mathematica to store/assign a value to a variable 
> whose name is in a string?  In other words something like this:
> 
> i = 17;
> foo="var" + ToString[i];
> SomeFunctionThatConvertsStringToSymbolName[foo] = 17;
> 
> and then assign some value (say, 23) to the variable whose name is 
> contained in the foo string? (i.e. var17=23)
> 
> Thanks!
> 
> 


  • Prev by Date: Re: Newbie Programming question
  • Next by Date: Re: [Newbie] Ohm, Ampere, Volt units
  • Previous by thread: Re: Newbie Programming question
  • Next by thread: Re: Newbie Programming question