[Haskell-cafe] Follow up on 'GroupBy behavior'
Hans van Thiel
hthiel.char at zonnet.nl
Sat Apr 28 15:15:55 EDT 2007
Thanks again for the help, and, to follow up, this now does what I
need..
-- partitions a list according to an equivalence relation
partition1 :: (a -> a -> Bool) -> [a] -> ([a],[a])
partition1 eq ls = partition ((head ls) `eq`) ls
--
partitionBy :: (a -> a -> Bool) -> [a] -> [[a]]
partitionBy eq [] = []
partitionBy eq ls =
(fst x):(partitionBy eq (snd x)) where
x = partition1 eq ls
Regards,
Hans van Thiel
More information about the Haskell-Cafe
mailing list