
28 Apr
2007
28 Apr
'07
10:08 a.m.
Hi Hans,
The standard function groupBy of List.hs doesn't work as I expect in this case:
groupBy (\x y -> (last x) == (last y)) ["abc", "bd","cac"]
You are doing something wrong. groupBy is specified to never reorder elements. You probably want to use sortBy first.
I have a defined groupSetBy which does groupBy working as though the list was in fact a set (which is often what it really is). Its a common thing to want - perhaps it should be a library function. Thanks Neil