sublist
lib.lists.sublist
Docs pulled from | This Revision | 14 minutes ago
Return a list consisting of at most count
elements of list
,
starting at index start
.
Inputs
start
-
Index at which to start the sublist
count
-
Number of elements to take
list
-
Input list
Type
sublist :: int -> int -> [a] -> [a]
Examples
lib.lists.sublist
usage example
sublist 1 3 [ "a" "b" "c" "d" "e" ]
=> [ "b" "c" "d" ]
sublist 1 3 [ ]
=> [ ]
Noogle detected
Implementation
The following is the current implementation of this function.
sublist =
start:
count:
list:
let len = length list; in
genList
(n: elemAt list (n + start))
(if start >= len then 0
else if start + count > len then len - start
else count);