Re: Assigning to a sublist
- To: mathgroup at smc.vnet.net
- Subject: [mg35173] Re: Assigning to a sublist
- From: Peter Pein <petsie at arcor.de>
- Date: Fri, 28 Jun 2002 02:31:03 -0400 (EDT)
- Organization: Arcor
- References: <afe4lv$h2h$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Bob, I didn't participate in writing the Mathematica-kernel, but I think it has z[[3]] as a temporary, unnamed reference, when trying z[[3]][[2]]=sth. It works fine, if you type: In[2]:= zz[[3,2]] = Append[zz[[3,2]], {1, 1, 1, 1, 1}] Out[2]= {{2, 1}, {1, 1, 1, 1, 1}} In[3]:= zz Out[3]= {{2, {{1, 1}}}, {10, {{3, 1}}}, {5, {{2, 1}, {1, 1, 1, 1, 1}}}} Peter Bob Harris wrote: > Howdy, > > I'm trying to assign a new value to an entry in a sublist (of another list), > and I can't understand why it won't work. > > For example, I do the following: > > In[1]:= zz = {{2, {{1, 1}}}, {10, {{3, 1}}}, {5, {{2, 1}}}} > Out[1]= {{2, {{1, 1}}}, {10, {{3, 1}}}, {5, {{2, 1}}}} > > In[2]:= zz[[3]][[2]] > Out[2]= {{2, 1}} > > In[3]:= Append[zz[[3]][[2]], {1, 1, 1, 1, 1}] > Out[3]= {{2, 1}, {1, 1, 1, 1, 1}} > > In[4]:= zz[[3]][[2]] = Append[zz[[3]][[2]], {1, 1, 1, 1, 1}] > Set::"setps : zz[[3]] in assignment of part is not a symbol." > Out[4]= {{2, 1}, {1, 1, 1, 1, 1}} <snip> > > Thanks, > Bob H > >