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


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

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-23 07:41 +0000
Message-ID <l1orbp$jel$1@smc.vnet.net> (permalink)
References <20130921083830.751226A65@smc.vnet.net> <201309220228.36832.itais@wolfram.com>
Organization Time-Warner Telecom

Show all headers | View raw


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

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-23 07:41 +0000

csiph-web