Re: a[[2]][[3]] = 1 error? why?
- To: mathgroup at smc.vnet.net
- Subject: [mg8930] Re: [mg8874] a[[2]][[3]] = 1 error? why?
- From: David Withoff <withoff>
- Date: Sat, 4 Oct 1997 22:08:08 -0400
- Sender: owner-wri-mathgroup at wolfram.com
> 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?
This could presumably be made to work, but Part assignments are a
rather special type of assignment, and in current versions of
Mathematica have only been made to work for a single level of Part,
not for nested Part. a[[2]][[3]] is Part[Part[a, 2], 3]. You
can make an assignment to the [[2,3]] element of this array
using a[[2,3]] instead, as in
In[1]:= a=Table[i*j,{i,1,3},{j,1,3}];
In[2]:= a[[2,3]] = 3
Out[2]= 3
In[3]:= a
Out[3]= {{1, 2, 3}, {2, 4, 3}, {3, 6, 9}}
Dave Withoff
Wolfram Research