
22 Mar
2014
22 Mar
'14
2:29 p.m.
Am 03/22/2014 06:40 PM, schrieb Kim-Ee Yeoh:
On Sat, Mar 22, 2014 at 11:51 PM, martin
mailto:martin.drautzburg@web.de> wrote: How can I groupBy a List whose elements are only instances of Eq but not of Ord?
If you take a look at the code for groupBy:
groupBy :: (a -> a -> Bool) -> [a] -> [[a]] groupBy _ [] = [] groupBy eq (x:xs) = (x:ys) : groupBy eq zs
Cool! I have a database background and the SQL "group by" does of course not assume any ordering. So I often wonder, where you would use Haskell's groupBy WITHOUT sorting first, but I assume there are situations, where this is useful.