Re: Replacing Parts of a List
- To: mathgroup at smc.vnet.net
- Subject: [mg28760] Re: Replacing Parts of a List
- From: Ignacio Rodriguez <ignacio at sgirmn.pluri.ucm.es>
- Date: Fri, 11 May 2001 20:00:38 -0400 (EDT)
- Organization: UCM
- References: <9dg63q$j5c@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I guess you want to do the following: you have Subscript[x,y] and want to set x=10 What you said seems OK for me: Subscript[x,y]=ReplacePart[Subscript[x,y],10,1] If you want something simpler, try x=10 If you prefer to have x as a function of Subscript[x,y], then you can use Evaluate[Subscript[x,y][[1]]]=10 you may see that lhs is x. As Set has Attribute HoldFirst, lhs is not evaluated unless you explicitly do so. Roger Jones 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 -- °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° Ignacio Rodriguez Ramirez de Arellano Unidad de RMN Universidad Complutense Paseo Juan XXIII, 1 Madrid 28040, Spain Tel. 34-91-394-3288 Fax 34-91-394-3245 e-mail: ignacio at sgirmn.pluri.ucm.es °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°