An alternative definition for Data.List.groupBy
10/02/2010The function groupBy from haskell’s standard library is defined in terms of span, the effect being that the supplied predicate function is used to compare the first element of a group with successive elements.
This isn’t clear from the docs, and you might try to do this and wonder at the output you got:
*Main> groupBy (< =) [3,4,5,3,2,1,4,4,1,1,2,3,4,5,4,5,6,7] [[3,4,5,3],[2],[1,4,4,1,1,2,3,4,5,4,5,6,7]]