Skip to content

Instantly share code, notes, and snippets.

@yuga
Created January 20, 2013 15:21
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 yuga/4579319 to your computer and use it in GitHub Desktop.
Save yuga/4579319 to your computer and use it in GitHub Desktop.
改行でstring分割
lines' :: String -> [String]
lines' s = go id s
where
go ac [] = [ac ""]
go ac ('\r':'\n':cs) = ac "" : go id cs
go ac ('\r' :cs) = ac "" : go id cs
go ac ( '\n':cs) = ac "" : go id cs
go ac ( c:cs) = go (ac . (c:)) cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment