Proposal: Add split and splitWith (trac #2048)

Twan van Laarhoven twanvl at gmail.com
Wed Jan 16 18:00:37 EST 2008


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

Twan


More information about the Libraries mailing list