Proposal: Add split and splitWith (trac #2048)

Henning Thielemann lemming at henning-thielemann.de
Thu Jan 17 01:54:24 EST 2008


On Thu, 17 Jan 2008, Henning Thielemann wrote:

> On Thu, 17 Jan 2008, Ian Lynagh wrote:
>
> > One or the other should be changed so that these agree:
> >
> > *Main> split 'a' ""
> > [""]
> > *Main> Data.ByteString.Char8.split 'a' (Data.ByteString.Char8.pack "")
> > Loading package array-0.1.0.0 ... linking ... done.
> > Loading package bytestring-0.9.0.1 ... linking ... done.
> > []
> >
> > although I couldn't say which is "right" OTTOMH...
>
> List's split is more consistent. It always returns a non-empty list. The
> number of sub-lists is the number of matching elements plus 1.

For QuickCheck:
  1 + length (filter p xs) == length (split p xs)


More information about the Libraries mailing list