MathGroup Archive 2009

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

Search the Archive

Re: Assigning Values to Many Symbols at Once

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101739] Re: [mg101699] Assigning Values to Many Symbols at Once
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Wed, 15 Jul 2009 07:13:22 -0400 (EDT)
  • References: <200907141200.IAA05959@smc.vnet.net>

On Jul 14, 2009, at 8:00 AM, Gregory Lypny wrote:

> Hello everyone,
>
> I can create a bunch of symbols on the fly using the Symbol command,
> as in
>
> 	Table[Symbol["x" <> ToString[i]], {i, 5}]
>
> to get
>
> 	{x1,x2,x3,x4,x5}
>
> But how can I assign values to these all at once?

One option is something like:

MapThread[(#=#2)&,{Table[Symbol["x" <> ToString[i]], {i, 5}],Table 
["value" <> ToString[i],{i,5}]}]

but you can't do this twice since the once the symbols are associated  
with values the evaluator with evaluate the symbol then attempt to  
assign the value resulting in assignment to a raw object.

Regards,

Ssezi


  • Prev by Date: Re: Refine, assumptions, domains
  • Next by Date: Re: Refine, assumptions, domains
  • Previous by thread: Re: Assigning Values to Many Symbols at Once
  • Next by thread: Re: Assigning Values to Many Symbols at Once