MathGroup Archive 2013

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

Search the Archive

Re: list mutability (very basic question)


On 9/22/2013 3:28 AM, Itai Seggev wrote:> Do you think that 0=1 should not be an error?  If
 > you think it should be an error (as it is in every language I'm familiar with),
 > then why should {0}[[1]]=1, which would essentially be the same thing, not be
 > an error?


Because I do not expect this syntax to lead to the LHS to be evaluated to 0.
I expect it to mean: replace the first element of the list {0} with the value 1.
(Compare Python: ``[0][0]=1`` is not an error, for exactly this reason.)
In fact this is a key point of puzzlement for me:
why ``x={0};x[[1]]=1`` is ok but ``{0}[[1]]=1`` is an error in Mathematica.
What is the evaluation rule for the LHS that produces this difference?

Thanks,
Alan




  • Prev by Date: Re: Import CSV can not understand string correctly
  • 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)