Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3252

Re: Assigning part of indexed object

From Heike Gramberg <heike.gramberg@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Assigning part of indexed object
Date 2011-06-23 11:33 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <itv89v$peh$1@smc.vnet.net> (permalink)
References <201106221129.HAA09151@smc.vnet.net>

Show all headers | View raw


This should work:

m[1] = ReplacePart[m[1], 1 -> 10]

Heike

On 22 Jun 2011, at 12:29, Fabrice P. Laussy wrote:

> How do you set the part of an indexed object, say:
> 
> m[1] = Range[5];
> 
> is my indexed object (I could have m[2], etc.). Now I 
> want to do something like:
> 
> m[1][[1]] = 10;
> 
> with effect of having m[1] read:
> 
> {10, 2, 3, 4, 5}
> 
> but of course the line above evaluates to 1 = 10.
> 
> This could be achieved by having a non-indexed object get 
> in the way, e.g., m1=m[1], assign m1 and then return to 
> m[1]=m1, but I believe there should a more elegant way.
> 

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Assigning part of indexed object Heike Gramberg <heike.gramberg@gmail.com> - 2011-06-23 11:33 +0000

csiph-web