Skip to content

Instantly share code, notes, and snippets.

@raine
Last active June 24, 2018 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raine/ffd6ac689a34c1bc14609733e47d98e5 to your computer and use it in GitHub Desktop.
Save raine/ffd6ac689a34c1bc14609733e47d98e5 to your computer and use it in GitHub Desktop.
split :: Char -> String -> (String, String)
split c str = (start, rest)
where start = takeWhile (/= c) str
rest = dropWhile (== c) $ dropWhile (/= c) str
myWords :: String -> [String]
myWords [] = []
myWords str = start : (myWords rest)
where (start, rest) = split ' ' str
myLines :: String -> [String]
myLines [] = []
myLines str = start : (myLines rest)
where (start, rest) = split '\n' str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment