[Haskell-cafe] wordsBy in the base libraries?
gale at sefer.org
Mon Oct 22 06:32:11 EDT 2007
Neil Mitchell wrote:
> You are still over by one test. Try instead:
> wordsBy :: (a -> Bool) -> [a] -> [[a]]
> wordsBy p s = case dropWhile p s of
>  -> 
> s':rest -> (s':w) : wordsBy p (drop 1 s'')
> where (w, s'') = break p rest
This still has the redundant empty list tests,
and in fact introduces another one in drop 1,
as well as some gratuitous arithmetic.
More information about the Haskell-Cafe