last
lib.last
Docs pulled from | This Revision | 18 days ago
Nixpkgs manual
Returns the last element of a list.
This function throws an error if the list is empty.
Inputs
list-
1. Function argument
Type
last :: [a] -> a
Examples
Noogle detected
Implementation
The following is the current implementation of this function.
last =
list:
assert list != [ ] || throw "lists.last: list must not be empty!";
elemAt list (length list - 1);