MathGroup Archive 1997

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

Search the Archive

Re: a[[2]][[3]] = 1 error? why?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8899] Re: a[[2]][[3]] = 1 error? why?
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Thu, 2 Oct 1997 22:56:52 -0400
  • Organization: University of Western Australia
  • Sender: owner-wri-mathgroup at wolfram.com

charles loboz wrote:

> a=Table[i*j,{i,1,3},{j,1,3}];
> a[[2]][[3]]
> 
> answer : 6 (as it should be)
> so why assignment to
> a[[2]][[3]] = 3
> doesn't work?

  In[1]:= a = Table[i*j, {i, 1, 3}, {j, 1, 3}]; 

  In[2]:= a[[2]][[3]]
  Out[2]= 6

Entering

  In[3]:= a[[2]][[3]] = 3

results in

 Set::"setps": a[[2]] in assignment of part is not a symbol."

  Out[3]= 3

which tells you that you cannot use this syntax (i.e. you cannot use Set
or =) because a[[2]] is not a symbol.  However, you can do what you want
using the alternative syntax

  In[4]:= a[[2,3]] = 3
  Out[4]= 3

The full matrix reads:

  In[5]:= a
  Out[5]= {{1, 2, 3}, {2, 4, 3}, {3, 6, 9}}

Cheers,
	Paul 
 
____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia           
Nedlands WA  6907                     mailto:paul at physics.uwa.edu.au 
AUSTRALIA                             http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: Re: FindRoot
  • Next by Date: Re: Problem/Bug w/ StackedBarChart?
  • Previous by thread: RE: a[[2]][[3]] = 1 error? why?
  • Next by thread: Re: a[[2]][[3]] = 1 error? why?