Re: Replacing Parts of a List
- To: mathgroup at smc.vnet.net
- Subject: [mg28757] Re: [mg28742] Replacing Parts of a List
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Fri, 11 May 2001 20:00:35 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I am not sure if I understand you correctly. The way I see it the situation
is exactly the same with Subscript as it is with List. Compare:
In[1]:=
l={a,b};l[[2]]=3;l
Out[1]=
{a, 3}
In[2]:=
Clear[l]
In[3]:=
l=Subscript[a,b];l[[2]]=3;l
Out[3]=
a
3
Same behaviour. Equally, neither {a, b}[[2]] = 3 nor Subscript[a,b][[2]]=3
will work and for the same reason.
Perhaps I have missed your point? Could you be more explicit?
--
Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/~andrzej/
on 01.5.11 4:38 PM, Roger Jones at rmj at SLAC.Stanford.EDU wrote:
> Given x={1,2} then setting part 1 to 10 (say) is done via x[[1]]=10.
> This
> appealing as it is a condensed notation and is I believe, very
> efficient for large
> arrays.
>
> However, with a subscripted symbol (such as Subscript[x,y]) how is it
> done?
>
> It can be achieved with Subscript[x,y]=ReplacePart[Subscript[x,y],10,1]
> but this is a little unwieldy.
>
> Is there some method (using Hold[Subscript[x,y]] or something like this)
>
> that allows a direct replacement?
>
> Thank you!
>
> -Roger Jones
>
>
>
>
>