Re: Array

*To*: mathgroup at smc.vnet.net*Subject*: [mg69239] Re: [mg69220] Array*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Sun, 3 Sep 2006 23:46:23 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

On 3 Sep 2006, at 06:39, Bruce Colletti wrote: > The command: > > {A[1], A[2], A[3]} = {1, 2, 3} > > assigns a value to each A-variable. However, the command: > > Array[A,3] = {1,2,3} > > generates an error message. > > What is the difference between the two lines? > > Thankx. > > Bruce > Set (=) works in a special way when you make assignments to lists, as stated in the Help: ?Set "lhs = rhs evaluates rhs and assigns the result to be the value \ of lhs. From then on, lhs is replaced by rhs whenever it appears. {l1, l2, \ ... } = {r1, r2, ... } evaluates the ri, and assigns the results to be the \ values of the corresponding li. This is why your first example works. However, since Set does not evaluate its first argument, it tries to assign a rule to the symbol Array, which it can't do since Array is Protected. Hence what you should use is: Evaluate[Array[A,3]]={1,2,3} which will work exactly as the first example. Andrzej Kozlowski