
28 Apr
2007
28 Apr
'07
10:36 a.m.
On Sat, 2007-04-28 at 15:08 +0100, Neil Mitchell wrote:
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. And thanks again. I'll roll my own then..
Hans
Thanks
Neil