Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Newbie Programming question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53448] Re: [mg53436] Newbie Programming question
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Wed, 12 Jan 2005 03:41:19 -0500 (EST)
  • References: <200501110632.BAA00755@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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