6 print $ [1,2,3] \\ [2,3]
16 assertEquals :: Show a => a -> a -> <Proc> ()
17 assertEquals a b = if a == b then () else fail "\(a) <> \(b)"
19 testGrouping outVal f l = do
20 kl = map (\v -> (f v, v)) l
24 assertEquals groups (groupBy f l)
26 i1 = fromMaybe [] . index groups
30 keys = map fst groups + [outVal]
33 assertEquals (i1 k) (i2 k)
34 assertEquals (i1 k) (i3 k)
37 testGrouping 4 (`mod` 3) [2,4,6,8,10]
39 [(2, [2, 8]), (1, [4, 10]), (0, [6])]