Created
May 8, 2014 23:54
-
-
Save joneshf/cbdf67774cf4a348229a to your computer and use it in GitHub Desktop.
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
module Foo where | |
groupBy :: forall a. (a -> a -> Boolean) -> [a] -> [[a]] | |
groupBy _ [] = [] | |
groupBy eq (x:xs) = case span (eq x) xs of | |
{init = ys, rest = zs} -> (x:ys) : groupBy eq zs | |
span :: forall a. (a -> Boolean) -> [a] -> { init :: [a], rest :: [a] } | |
span p (x:xs') | p x = case span p xs' of {init = ys, rest = zs} -> {init: (x:ys), rest: zs} | |
span _ xs = {init: [], rest: xs} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment