toWords :: String -> [String] toWords x | length x == 0 = [] | otherwise = takeWhile (/= ' ') x : toWords (drop 1 (dropWhile (/= ' ') x))