The source code of groupBy shows that groupBy does not go through every element. Is it really possible to implement it using folds? Thanks.
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