Hi,

The source code of groupBy shows that groupBy does not go through every element. Is it really possible to implement it using folds? Thanks.

-- | 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


Best regards,
Zhi-Qiang Lei
zhiqiang.lei@gmail.com