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


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

Re: list mutability (very basic question)

From Alan G Isaac <alan.isaac@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: list mutability (very basic question)
Date 2013-09-22 06:41 +0000
Message-ID <l1m3ea$cdh$1@smc.vnet.net> (permalink)
References <20130921083830.751226A65@smc.vnet.net> <CAEtRDScmG_YsoM-NJHfkvJV74gKmLeQCB8xknARWW9L3v31zaQ@mail.gmail.com>
Organization Time-Warner Telecom

Show all headers | View raw


On 9/21/2013 10:15 AM, Bob Hanlon wrote:
 > Attributes[Set]
 > {HoldFirst, Protected, SequenceHold}


Thanks, but I'm still unclear:
why does ``{0}[[1]]=1`` raise an error?

As a point of reference for my confusion,
Python behaves in a way I find more intuitive:
``[0,1][1]=0`` does not raise an error.
(This becomes an interesting difference when
we get to argument passing in Mathematica, where HoldFirst
becomes useful as a way to allow "in place" modification.)

Back to Mathematica, am I understanding correctly that after
``Set[Part[x,1],1])`` that x still references the
same location in memory?  How can I easily see that?
(E.g., in Python, I would us the ``id`` function.)

Thanks,
Alan Isaac

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


Thread

Re: list mutability (very basic question) Alan G Isaac <alan.isaac@gmail.com> - 2013-09-22 06:41 +0000

csiph-web