toWords.hs
· 141 B · Haskell
Raw
toWords :: String -> [String]
toWords x
| length x == 0 = []
| otherwise = takeWhile (/= ' ') x : toWords (drop 1 (dropWhile (/= ' ') x))
1 | toWords :: String -> [String] |
2 | toWords x |
3 | | length x == 0 = [] |
4 | | otherwise = takeWhile (/= ' ') x : toWords (drop 1 (dropWhile (/= ' ') x)) |