Created
July 21, 2019 18:38
-
-
Save owen-d/ad106a405b0ecf91463b14e616d19db6 to your computer and use it in GitHub Desktop.
contiguous sublists of n length in haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sublists :: Int -> [a] -> [[a]] | |
sublists n xs = filter (\x -> length x == n) $ contiguous n xs | |
where | |
contiguous _ [] = [] | |
contiguous n (x:xs) = | |
take n (x:xs) : contiguous n xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment