gives the first element in expr.


gives the first element if it exists, or def otherwise.


  • First[expr] is equivalent to expr[[1]].
  • First has attribute HoldRest. In First[expr,def], def is evaluated only if it is to be returned.


open allclose all

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)

First works on SparseArray objects:

First extracts the first value in an Association:

Properties & Relations  (1)

First[expr] is equivalent to expr[[1]]:

Possible Issues  (2)

The expression is evaluated before First is applied:

First always operates on the FullForm of expressions:

Introduced in 1988
Updated in 2014