Skip to content

Instantly share code, notes, and snippets.

@tgdn
Last active December 8, 2016 00:46
Show Gist options
  • Save tgdn/44a56edafa1a3e2e0f780b12a9e7a3fe to your computer and use it in GitHub Desktop.
Save tgdn/44a56edafa1a3e2e0f780b12a9e7a3fe to your computer and use it in GitHub Desktop.
breakLines :: String -> [String]
breakLines s = br (s, "", [])
where
br :: (String, String, [String]) -> [String]
br ("", ss, ll) = ll ++ [ss]
br (x:xs, ss, ll)
| x == '\n' = br (xs, "", ll ++ [ss])
| otherwise = br (xs, ss ++ [x], ll)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment