As explained in the manual :
[] , , ,... []... REPL, , .
, windowl , , assert_smaller construction:
total
windowl : Nat -> List a -> List (List a)
windowl size = loop
where
loop : List a -> List (List a)
loop xs = case List.splitAt size xs of
(ys, []) => if length ys == size then [ys] else []
(ys, _) => ys :: loop (assert_smaller xs $ drop 1 xs)
loop, :
total
windowl : Nat -> List a -> List (List a)
windowl size = loop
where
loop : List a -> List (List a)
loop [] = []
loop xs@(x :: xs') = case List.splitAt size xs of
(ys, []) => if length ys == size then [ys] else []
(ys, _) => ys :: loop xs'
, , hardcoded drop 1 , . .
REPL :
λΠ> windowl 2 [1,2,3,4,5]
[[1, 2], [2, 3], [3, 4], [4, 5]] : List (List Integer)