Timeline for Taking a Part of a Part of a Variable
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 17, 2018 at 13:48 | vote | accept | LBogaardt | ||
Sep 14, 2018 at 15:00 | history | tweeted | twitter.com/StackMma/status/1040616253730312192 | ||
Sep 14, 2018 at 13:57 | answer | added | LBogaardt | timeline score: 2 | |
Sep 14, 2018 at 13:51 | history | edited | LBogaardt | CC BY-SA 4.0 |
edited tags; edited title
|
Sep 14, 2018 at 13:51 | comment | added | Sjoerd Smit |
Evaluate will not do anything here since there's no hold attribute to override (see also mathematica.stackexchange.com/a/180500/43522) . Mathematica tries to evaluate Part[y, 1] , but since there's nothing it can evaluate to, it stays the way it is. That's how Mathematica handles most ill-defined expressions: it's part of the symbolic nature of the language. Mathematica uses a term-rewriting style of evaluation and when there's no applicable rules available, things just stay the way they are.
|
|
Sep 14, 2018 at 13:47 | comment | added | LBogaardt |
@SjoerdSmit Ah, that makes sense. Though adding an Evaluate around the inner Part doesn't seem to work. The Indexed solution is much nicer anyway, as it also doesn't require the Quiet .
|
|
Sep 14, 2018 at 13:45 | comment | added | Sjoerd Smit |
You get y because Part[y, 1] doesn't evaluate if y is atomic. So the outer Part then extracts the first argument of Part[y,1] , which is y . This is because Part works on arbitrary expression, not just List s
|
|
Sep 14, 2018 at 13:37 | history | edited | LBogaardt | CC BY-SA 4.0 |
deleted 144 characters in body; edited title
|
Sep 14, 2018 at 13:36 | comment | added | Henrik Schumacher |
A robust way would be to use Indexed instead of Part . See also here.
|
|
Sep 14, 2018 at 13:33 | history | asked | LBogaardt | CC BY-SA 4.0 |