Skip to content

Instantly share code, notes, and snippets.

@seanhess
Created April 10, 2015 16:28
Show Gist options
  • Save seanhess/a488ab7ceb49b9915d0f to your computer and use it in GitHub Desktop.
Save seanhess/a488ab7ceb49b9915d0f to your computer and use it in GitHub Desktop.
Take functions that work like span, and repeatedly apply them to consume a list
chunks :: ([a] -> ([a], [a])) -> [a] -> [[a]]
chunks f [] = []
chunks f xs = case c of
[] -> cs
ys -> ys : cs
where
(c, rest) = f xs
cs = chunks f rest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment