RE: Re: Replacing Parts of a List
- To: mathgroup at smc.vnet.net
- Subject: [mg28826] RE: [mg28771] Re: Replacing Parts of a List
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.de>
- Date: Tue, 15 May 2001 00:58:58 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Roger, things are a little bit tricky, since symbol[[indices]] is a special form in Mathematica. Trying to define Upvalues for Subscript didn't work for Set[Part[..]]. So an idea would be to modify parsing of a subcripted expression, and convert that to special symbols: In[1]:= MakeExpression[SubscriptBox[x_, y_], StandardForm] := MakeExpression[RowBox[{StringJoin["\[Section]", x, "\[Section]", y]}], StandardForm] In[2]:= \!\(x\_y\ = \ {1, 2, 3}\) Out[2]= {1, 2, 3} In[3]:= \!\(x\_y[\([3]\)] = 10\) Out[3]= 10 In[4]:= \!\(x\_y\) Out[4]= {1, 2, 10} so any piece of input Substring[x,y] is converted to an internal symbol §x§y (which will not come to your eye, if you give it a value at definition time, as done above). Try whether this will suffice to your purpose. Alternatively I've heard of a Package "Symbolize", which will do this (?) and other things, but I have neither used that nor studied. Good luck, -- Hartmut > -----Original Message----- > From: Roger Jones [mailto:rmj at SLAC.Stanford.EDU] To: mathgroup at smc.vnet.net > Sent: Saturday, May 12, 2001 7:37 AM > To: mathgroup at smc.vnet.net > Subject: [mg28826] [mg28771] Re: Replacing Parts of a List > > > To clarify > > In[1]:=Subscript[x, y] = {1, 2, 3} > > Out1]={1, 2, 3} > > To replace the third element I must use : > > In[2]:=Subscript[x, y] = ReplacePart[Subscript[x, y], 10, 3] > > Out[2]={1, 2,10} > > So that now Subscript[x, y] gives: > > In[3]:=Subscript[x, y] > > Out[3]={1, 2, 10} > > > This is unwieldy and I was hoping for a little more condensed > notation. > However, > when using subscripts this appears appears to be the simplist notation > available. > > -Roger Jones > >