|
module Itertools (
|
|
flatmap,
|
|
windows
|
|
) where
|
|
|
|
windows :: Int -> [a] -> [[a]]
|
|
windows _ [] = []
|
|
windows i (x:xs)
|
|
| length xs < i-1 = []
|
|
| otherwise = (x:take (i-1) xs):windows i xs
|
|
|
|
flatmap :: (t -> [a]) -> [t] -> [a]
|
|
flatmap _ [] = []
|
|
flatmap f (x:xs) = f x ++ flatmap f xs
|