Proposal: Add split and splitWith (trac #2048)

Simon Marlow simonmarhaskell at gmail.com
Fri Jan 18 08:28:21 EST 2008


Twan van Laarhoven wrote:
> Hello Haskellers,
> 
> 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

Those interested in contributing to this discussion might like to review 
some of the past threads on this topic :-)

http://www.haskell.org/pipermail/libraries/2006-July/005504.html
http://www.haskell.org/pipermail/libraries/2006-July/005499.html
http://www.haskell.org/pipermail/libraries/2006-July/005525.html
http://www.haskell.org/pipermail/libraries/2006-October/006072.html

and I'm sure there are earlier threads, but the above probably covers 
enough of the design space.

Cheers,
	Simon



More information about the Libraries mailing list