@@ -0,0 +1,24 @@
3+||| The groupBy function returns a list of lists such that the concatenation
4+||| of the list is equal to the argument, and each sublist contains only
5+||| elements that are equal according to the user-supplied predicate.
8+||| groupBy (==) [1, 1, 2, 3, 3]
11+groupBy : (a -> a -> Bool) -> List a -> List (List a)
13+groupBy p list@(x :: xs) =
14+ let (ys, zs) = span (p x) xs in
15+ (x :: ys) :: groupBy p (assert_smaller list zs)
17+||| The group function is a special case of groupBy.
20+||| group [1, 1, 2, 3, 3]
23+group : Eq a => List a -> List (List a)