
22 Oct
2007
22 Oct
'07
10:32 a.m.
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. -Yitz