Proposal (Trac ticket #3671): Add takeRec, genericTakeRec and
spanRec to Data.List
gale at sefer.org
Thu Nov 19 07:07:10 EST 2009
Ian Lynagh wrote:
> breaks (',' ==) "123,456,,78" == ["123", "456", "", "78"]
Yes, that is very useful, and we get the other semantics
from "runs". So as of now, I am leaning towards:
runs = groupBy . on (==)
spans p = filter (p . head) . runs p
breaks p = filter (not . p . head) . runs p
> but personally I don't think this should be standardised.
All of these functions are very simple combinations of
existing ones. On the other hand, it took us until now
to realize that, so I'm not sure.
In any case, I definitely would like to see groupsOf
(or a rose by any other name) in the library.
More information about the Libraries