({{, (RefLink[SelectFirst, paclet:ref/SelectFirst])[{(Subscript[e, 1]),(Subscript[e, 2]),…},crit] 
gives the first (Subscript[e, i]) for which crit[(Subscript[e, i])] is (RefLink[True, paclet:ref/True]), or (RefLink[Missing, paclet:ref/Missing])["NotFound"] if none is found.}, {, (RefLink[SelectFirst, paclet:ref/SelectFirst])[{(Subscript[e, 1]),(Subscript[e, 2]),…},crit,default]
gives default if there is no (Subscript[e, i]) such that crit[(Subscript[e, i])] is (RefLink[True, paclet:ref/True]).}, {, (RefLink[SelectFirst, paclet:ref/SelectFirst])[crit]
represents an operator form of (RefLink[SelectFirst, paclet:ref/SelectFirst]) that can be applied to an expression.}})

OpenersNotesSection(Spacer1)Details

In (RefLink[SelectFirst, paclet:ref/SelectFirst])[{(Subscript[e, 1]),(Subscript[e, 2]),…},crit,default], default is only evaluated if there is no (Subscript[e, i]) such that crit[(Subscript[e, i])] is (RefLink[True, paclet:ref/True]).

(RefLink[SelectFirst, paclet:ref/SelectFirst])[crit][expr] is equivalent to (RefLink[SelectFirst, paclet:ref/SelectFirst])[expr,crit].

OpenersPrimaryExamplesSection(Spacer1)Examples  (13)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Select the first element that is even:

SelectFirst[{1,2,4,7,6,2},EvenQ]

Use a pure function to test elements:

SelectFirst[{1,2,4,7,6,2},#>2&]

Give the default x when no even numbers are found:

SelectFirst[{1,3,5},EvenQ,x]

(RefLink[SelectFirst, paclet:ref/SelectFirst]) operates on values in an (RefLink[Association, paclet:ref/Association]):

SelectFirst[<|a->1,b->2,c->3,d->4|>,#>2&]

OpenersExampleSection1(Spacer1)Scope  (3)

Use the operator form of (RefLink[SelectFirst, paclet:ref/SelectFirst]):

SelectFirst[EvenQ][{1,2,4,7,6,2}]

Find the first pair containing x:

SelectFirst[{{1,y},{2,z},{3,x},{4,y}, {5,x}},MemberQ[#,x]&]

Use a custom default value:

SelectFirst[{1,2,3},StringQ,"NoStrings"]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (2)

(RefLink[SelectFirst, paclet:ref/SelectFirst]) works with any head, not just (RefLink[List, paclet:ref/List]):

SelectFirst[f[1,a,2,b,3],IntegerQ]

(RefLink[SelectFirst, paclet:ref/SelectFirst]) works with (RefLink[SparseArray, paclet:ref/SparseArray]) objects:

s = SparseArray[Table[2^i->i,{i,0,5}]]

SelectFirst[s,EvenQ]

OpenersExampleSection4(Spacer1)Properties & Relations  (4)

The default value is only evaluated if needed:

SelectFirst[{1015177, "Junk",EndOfFile},PrimeQ,
Print["CriticalError"];$Failed]

SelectFirst[{1015177, 2015177,3015177},PrimeQ,
Print["CriticalError"];$Failed]

(RefLink[SelectFirst, paclet:ref/SelectFirst]) returns only the first match:

SelectFirst[{"1", a,Pi,(Sqrt[2]),E},NumericQ]

(RefLink[Select, paclet:ref/Select]) returns all matches:

Select[{"1", a,Pi,(Sqrt[2]),E},NumericQ]

(RefLink[SelectFirst, paclet:ref/SelectFirst]) can be implemented with a combination of (RefLink[Select, paclet:ref/Select]) and (RefLink[Replace, paclet:ref/Replace]):

SelectFirst[{"1", a,Pi,(Sqrt[2]),E},NumericQ]
SelectFirst[{"1", a,Pi,(Sqrt[2]),E},PrimeQ]

Replace[Select[{"1", a,Pi,(Sqrt[2]),E},NumericQ],{{}:>Missing["NotFound"],l_:>First[l]}]
Replace[Select[{"1", a,Pi,(Sqrt[2]),E},PrimeQ],{{}:>Missing["NotFound"],l_:>First[l]}]

(RefLink[SelectFirst, paclet:ref/SelectFirst]) is similar to (RefLink[FirstCase, paclet:ref/FirstCase]) except that it uses a function instead of a pattern:

list = RandomInteger[{3,7},{10,2}]

Select the first list that has a sum of elements less than 10:

f=Total[#]<10&;

SelectFirst[list,f]

Use (RefLink[FirstCase, paclet:ref/FirstCase]) to get the same result:

FirstCase[list,x_/;f[x]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Select, paclet:ref/Select])  ▪  (RefLink[FirstCase, paclet:ref/FirstCase])  ▪  (RefLink[FirstPosition, paclet:ref/FirstPosition])  ▪  (RefLink[First, paclet:ref/First])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Elements of Lists, paclet:guide/ElementsOfLists])}, {▪(RefLinkPlain[Computation with Structured Datasets, paclet:guide/ComputationWithStructuredDatasets])}, {▪(RefLinkPlain[Function Composition & Operator Forms, paclet:guide/FunctionCompositionAndOperatorForms])}})}})