I'm having trouble understanding the difference between Cases and Position.
What I want to do is to identify the elements of a (twice) nested list for which the first list contained in it itself contains a particular integer. The following code correctly identifies these elements using "Cases"
snap = {{{1, 2, 3}, {a, b, c}}, {{2, 3, 4}, {d, e, f}}};
Cases[snap, x_ /; MemberQ[x[[1]], 1]]
This correctly returns: {{{1, 2, 3}, {a, b, c}}}
I would have expected the following code to do essentially the same thing but to return the positions of these elements within "snap" rather than the elements themselves.
Position[snap, x_ /; MemberQ[x[[1]], 1]]
However this generates an error (multiple times before stopping):
"Part specification List[[1]] is longer than depth of object."
Can someone explain why Position doesn't behave just like Cases? And is there an easy way to get the positions of the elements that match my pattern?
Thank you!
Headsoption and default levelspec. – Kuba Feb 15 '18 at 12:59