28 Apr
2007
28 Apr
'07
9:49 p.m.
Hello All, 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"] results in: [["abc"],["bd"],["cac"]] where I want: [["abc","cac"], ["bd"]] Am I doing something wrong, or is this a bug? The function is defined (in List.hs in the hugs Data library) as : -- | The 'groupBy' function is the non-overloaded version of 'group'. groupBy :: (a -> a -> Bool) -> [a] -> [[a]] groupBy _ [] = [] groupBy eq (x:xs) = (x:ys) : groupBy eq zs where (ys,zs) = span (eq x) xs Thanks, Hans van Thiel