init
lib.lists.init
Docs pulled from | This Revision | 11 minutes ago
Return all elements but the last.
This function throws an error if the list is empty.
Inputs
list
-
1. Function argument
Type
init :: [a] -> [a]
Examples
lib.lists.init
usage example
init [ 1 2 3 ]
=> [ 1 2 ]
Noogle detected
Implementation
The following is the current implementation of this function.
init = list:
assert lib.assertMsg (list != []) "lists.init: list must not be empty!";
take (length list - 1) list;