Proposal: Add split and splitWith (trac #2048)

Don Stewart dons at galois.com
Wed Jan 16 18:32:46 EST 2008


ndmitchell:
> Hi
> 
> > An often requested function is 'split', to split a list into parts delimited by
> > some separator. ByteString has the functions split and splitWith for this
> > purpose. I propose we add equivalents to Data.List:
> >
> >  > split :: Eq a => a -> [a] -> [[a]]
> >  > split x = splitWith (x==)
> >  >
> >  > splitWith :: (a -> Bool) -> [a] -> [[a]]
> >  > splitWith p xs = ys : case zs of
> >  >                         []   -> []
> >  >                         _:ws -> splitWith p ws
> >  >                   where (ys,zs) = break p xs
> >
> > trac: http://hackage.haskell.org/trac/ghc/ticket/2048
> > deadline: two weeks from now, January 30
> 
> (+10) Agreement. This is long overdue!

I'd like some QuickCheck properties, so we can avoid the unlines . lines /= id 
fiasco. Given that, I'd support this too.

-- Don


More information about the Libraries mailing list