MathGroup Archive 2005

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

Search the Archive

Re: Newbie Programming question


On Jan 11, 2005, at 1:32 AM, Kerry Kim wrote:

> 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)
>

You have to use Evaluate since Set has the attribute HoldFirst but the 
following does what you want

Evaluate[ToExpression[foo]]=17

Regards,

Ssezi


  • Prev by Date: Mathematica Graphics output in an ASP.NET WebApplication
  • Next by Date: Re: Mathematica is not very clever
  • Previous by thread: Newbie Programming question
  • Next by thread: Re: Newbie Programming question