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


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

Re: Assigning part of indexed object

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From Bob Hanlon <hanlonr@cox.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Assigning part of indexed object
Date Thu, 23 Jun 2011 11:28:13 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <itv80d$pc8$1@smc.vnet.net> (permalink)
Reply-To hanlonr@cox.net
Lines 35
NNTP-Posting-Date 23 Jun 2011 10:29:39 GMT
NNTP-Posting-Host 216cc023.news.twtelecom.net
X-Trace DXC=HB\g=:La=ke2hjn;A6STQiC_A=>8kQj6m=_1NR_H?JPm]n69LSK=I@bEFiONJ7[Gof;ZAFX;E@49i
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:3247

Show key headers only | View raw


m[1] = Range[5, 1, -1]

{5, 4, 3, 2, 1}

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

{10, 4, 3, 2, 1}


Bob Hanlon

---- "Fabrice P. Laussy" <fabrice.laussy@n0spam-gmail.com> 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 Bob Hanlon <hanlonr@cox.net> - 2011-06-23 11:28 +0000

csiph-web