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: [mg101731] Re: Assigning Values to Many Symbols at Once
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Wed, 15 Jul 2009 07:11:54 -0400 (EDT)

On 7/14/09 at 8:00 AM, gregory.lypny at videotron.ca (Gregory Lypny)
wrote:

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

Simply do x = y where x is the list of symbols to have assigned
values and y is the list of values use. For example,

In[1]:= {x1, x2, x3, x4, x5} == Range[5]
{x1, x2, x3, x4, x5} = Range[5];
{x1, x2, x3, x4, x5} == Range[5]

Out[1]= {x1,x2,x3,x4,x5}=={1,2,3,4,5}

Out[3]= True

The first equality test is returned unevaluated since the
symbols have no assigned value at that time. The second equality
test evaluates to True, showing the symbols did get assigned
values as expected.



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