WLJS LogoWLJS Notebook

SelectFirst

SelectFirst[data, crit] gives the first element for which crit[ei] is True, or Missing["NotFound"] if none is found.

Examples

Find first even number:

SelectFirst[{1, 3, 5, 6, 7, 8}, EvenQ]
(* 6 *)

With default value:

SelectFirst[{1, 3, 5}, EvenQ, "none"]
(* "none" *)

Please visit the official Wolfram Language Reference for more details.

On this page