Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Assigning part of indexed object
Replies: 12   Last Post: Jun 30, 2011 8:00 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
magma

Posts: 207
Registered: 7/5/07
Re: Assigning part of indexed object
Posted: Jun 23, 2011 7:26 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Jun 22, 1:29 pm, "Fabrice P. Laussy" <fabrice.lau...@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.


Use

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.