WLJS LogoWLJS Notebook

FirstCase

FirstCase[{e1, e2, ...}, pattern] gives the first element matching pattern, or Missing["NotFound"] if none is found.

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

Examples

Find first match:

FirstCase[{1, "a", 2, "b"}, _String]
(* "a" *)

With default:

FirstCase[{1, 2, 3}, _String, "none"]
(* "none" *)

Please visit the official Wolfram Language Reference for more details.

On this page