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: [mg101740] Re: [mg101699] Assigning Values to Many Symbols at Once
  • From: Zach Bjørnson <bjornson at mit.edu>
  • Date: Wed, 15 Jul 2009 07:13:34 -0400 (EDT)
  • References: <200907141200.IAA05959@smc.vnet.net>

Hi Gregory,

You can simply do list-to-list assignments:
{x1,x2,x3,x4,x5}={value1,value2,value3,value4,value5}

in whatever way you want, e.g.
Table[Symbol["x"<>ToString[i]],{i,5}]=Table[i,{i,5}]

Note that this is especially useful for doing parallel calculations to 
obtain values not derived from loops. E.g.
{x1,x2}={ParallelEvaluate[(*some long 
calculation*),{Kernels[][[1]]}],ParallelEvaluate[(*some different long 
calculation*),{Kernels[][[2]]}]}

Cheers,
Zach

On 7/14/2009 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?
>
> Regards,
>
> 	Gregory
>
>    


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