WLJS LogoWLJS Notebook

FirstPosition

FirstPosition[expr, pattern] gives the position of the first element matching pattern, or Missing["NotFound"] if none is found.

FirstPosition[expr, pattern, default] gives default if no match is found.

Examples

Find first position:

FirstPosition[{1, 2, 3, 2}, 2]
(* {2} *)

In nested lists:

FirstPosition[{{a, b}, {c, d}}, d]
(* {2, 2} *)

Please visit the official Wolfram Language Reference for more details.

On this page