Skip to main content
3 events
when toggle format what by license comment
Jan 7, 2023 at 22:19 comment added Ben Hekster Note that as given above, FirstPosition will apply at all levels (including the list as a whole) and at the list head: FirstPosition[{2, 4, 6, 8, 10}, x_ /; (Print[x]; x > 12)] prints List, 2, 4, 6, 8, 10, {2,4,6,8,10}. To get the expected behavior of only iterating over the list elements, you have to do something like FirstPosition[{2, 4, 6, 8, 10}, x_ /; x > 12, Null, {1}, Heads -> False] (or make the pattern more restrictive).
Nov 3, 2014 at 21:23 vote accept InquisitiveInquirer
Nov 3, 2014 at 20:17 history answered Artes CC BY-SA 3.0