gives the first element in expr.
gives the first element if it exists, or def otherwise.
- First[expr] is equivalent to expr[].
- First has attribute HoldRest. In First[expr,def], def is evaluated only if it is to be returned.
Basic Examples (5)
Extract the first element of a list:
Extract the first row of a matrix:
Extract the first element of an association:
The head need not be List:
Return x if there are zero elements:
Generalizations & Extensions (2)
Properties & Relations (1)
Introduced in 1988
Updated in 2015