/Prelude-v17.0.0/List/last

Copy path to clipboard

Examples

last Natural [ 0, 1, 2 ] ≡ Some 2
last Natural ([] : List Natural) ≡ None Natural

Source

{-
Retrieve the last element of the list
-}
let last
: ∀(a : Type) → List a → Optional a
= List/last

let example0 = assert : last Natural [ 0, 1, 2 ] ≡ Some 2

let example1 = assert : last Natural ([] : List Natural) ≡ None Natural

in last