Created
January 10, 2014 06:11
-
-
Save reinh/8347685 to your computer and use it in GitHub Desktop.
Comma separated list in Haskell. Uses an Oxford comma as God intended.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oxfordian [] = "" | |
oxfordian [x] = x | |
oxfordian [x,y] = x ++ " and " ++ y | |
oxfordian [x,y,z] = x ++ ", " ++ y ++ ", and " ++ z | |
oxfordian (x:xs) = x ++ ", " ++ oxfordian xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment