
10 Jun
2009
10 Jun
'09
5:16 a.m.
On Tue, 9 Jun 2009, Cale Gibbard wrote:
Similarly, groupBy f xs is (and should be) the unique list of contiguous sublists of xs such that: 1) concat (groupBy f xs) = xs 2) If x is the head of any of the sublists and y is any other element of that sublist, then f x y 3) The sequence of lengths of the sublists is lexicographically maximum for all lists satisfying the first two properties (That is, it always prefers adding elements to an earlier group to starting a new group.)
groupBy defined this way was found to be inappropriate for many cases, like grouping a list into increasing sequences using groupBy (<=). Other cases can be found in Haskell-Cafe or Libraries@haskell.org.