Proposal: Add split and splitWith (trac #2048)

Neil Mitchell ndmitchell at gmail.com
Wed Jan 16 18:29:51 EST 2008


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!

Thanks

Neil


More information about the Libraries mailing list