Created
December 19, 2014 05:37
-
-
Save carymrobbins/c9940097d5702f6b2a9f to your computer and use it in GitHub Desktop.
An implementation of groupBy which returns a list of mono traversable
This file contains hidden or 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
| import ClassyPrelude | |
| groupBy' :: IsSequence seq => (Element seq -> Element seq -> Bool) -> seq -> [MinLen (Succ Zero) seq] | |
| groupBy' eq s = case uncons s of | |
| Nothing -> mempty | |
| Just (x, xs) -> mlcons x (toMinLenZero ys) : groupBy' eq zs | |
| where | |
| (ys,zs) = span (eq x) xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment