[Date Index]
[Thread Index]
[Author Index]
Re: list mutability (very basic question)
*To*: mathgroup at smc.vnet.net
*Subject*: [mg131717] Re: list mutability (very basic question)
*From*: Murray Eisenberg <murray at math.umass.edu>
*Date*: Mon, 23 Sep 2013 21:58:50 -0400 (EDT)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*Delivered-to*: l-mathgroup@wolfram.com
*Delivered-to*: mathgroup-outx@smc.vnet.net
*Delivered-to*: mathgroup-newsendx@smc.vnet.net
*References*: <20130921083830.751226A65@smc.vnet.net> <CAEtRDScmG_YsoM-NJHfkvJV74gKmLeQCB8xknARWW9L3v31zaQ@mail.gmail.com> <20130922064701.8199B6A68@smc.vnet.net>
I missed the beginning of this thread, but I just wanted to note that the confusion is deepened when you contrast evaluating
{0}[[1]]
which causes an error, with evaluating each of the following two sequences of inputs:
x = {0};
x[[1]] = "Hello"'
x
{Hello}
{0}[[1]]
0
On Sep 22, 2013, at 2:47 AM, Alan G Isaac <alan.isaac at gmail.com> wrote:
> 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
---
Murray Eisenberg =
murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305
Prev by Date:
**Re: list mutability (very basic question)**
Next by Date:
**ExtendUnits package still works with old symbolic units**
Previous by thread:
**Re: list mutability (very basic question)**
Next by thread:
**Re: list mutability (very basic question)**
| |