
19 Nov
2009
19 Nov
'09
2:10 p.m.
On Thu, 2009-11-19 at 15:02 +0100, Philip K.F. Hölzenspies wrote:
runs :: (a -> Bool) -> [a] -> [[a]] runs = groupBy . on (==)
groupBy . on (==) :: (a -> ()) -> [a] -> [[a]]
Don't know what neuron misfired there... my apologies. I quickly tried it out in ghci:
let runs' = groupBy . on (==) :t runs' x :: (a -> ()) -> [a] -> [[a]]
but of course:
:t groupBy . on (==) groupBy . on (==) :: (Eq b) => (a -> b) -> [a] -> [[a]]
My bad. However, runs is still considerably more general and, AFAICT, not a composition of other Data.List functions. I agree with Ian that even if it took us a while to write those compositions properly, they shouldn't be in the library. I stand by runs, though ;) Regards, Philip