Say I have Part of a variable x.
Part[x, 1]
Then, I'll get an error message, as the variable x is not recognised as a list with multiple parts.
If I want to suppress this error, because I know for sure x will have multiple parts, I can use the Quiet function.
Quiet[Part[x, 1], {Part::partd}]
But now imagine that the list variable x itself is an element of another list y such that x=y[[1]].
Quiet[Part[Part[y, 1], 1], {Part::partd}]
I expect this to return y[[1][[1]], however, what I get is y.
Any ideas why this happens? Obviously the examples are simplified working examples, but it should work. How can I get my expected behaviour?
Indexedinstead ofPart. See also here. – Henrik Schumacher Sep 14 '18 at 13:36ybecausePart[y, 1]doesn't evaluate ifyis atomic. So the outerPartthen extracts the first argument ofPart[y,1], which isy. This is becausePartworks on arbitrary expression, not justLists – Sjoerd Smit Sep 14 '18 at 13:45Evaluatearound the innerPartdoesn't seem to work. TheIndexedsolution is much nicer anyway, as it also doesn't require theQuiet. – LBogaardt Sep 14 '18 at 13:47Evaluatewill not do anything here since there's no hold attribute to override (see also https://mathematica.stackexchange.com/a/180500/43522) . Mathematica tries to evaluatePart[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. – Sjoerd Smit Sep 14 '18 at 13:51