Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15517 > unrolled thread
| Started by | Alan G Isaac <alan.isaac@gmail.com> |
|---|---|
| First post | 2013-09-23 07:41 +0000 |
| Last post | 2013-09-23 07:41 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: list mutability (very basic question) Alan G Isaac <alan.isaac@gmail.com> - 2013-09-23 07:41 +0000
| From | Alan G Isaac <alan.isaac@gmail.com> |
|---|---|
| Date | 2013-09-23 07:41 +0000 |
| Subject | Re: list mutability (very basic question) |
| Message-ID | <l1orbp$jel$1@smc.vnet.net> |
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 top | Article view | comp.soft-sys.math.mathematica
csiph-web