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