take
lib.lists.take
Docs pulled from | This Revision | 18 days ago
Nixpkgs manual
Returns the first (at most) N elements of a list.
Inputs
count-
Number of elements to take
list-
Input list
Type
take :: Int -> [a] -> [a]
Examples
lib.lists.take usage example
take 2 [ "a" "b" "c" "d" ]
=> [ "a" "b" ]
take 2 [ ]
=> [ ]
Noogle detected
Implementation
The following is the current implementation of this function.
take =
count: list:
let
len = length list;
in
genList (elemAt list) (if count > len then len else count);