MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: list mutability (very basic question)


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



  • Prev by Date: DSolve: Gene production concentration
  • Next by Date: Re: list mutability (very basic question)
  • Previous by thread: Re: list mutability (very basic question)
  • Next by thread: Re: list mutability (very basic question)