Skip to content

Instantly share code, notes, and snippets.

@reinh
Created January 10, 2014 06:11
Show Gist options
  • Save reinh/8347685 to your computer and use it in GitHub Desktop.
Save reinh/8347685 to your computer and use it in GitHub Desktop.
Comma separated list in Haskell. Uses an Oxford comma as God intended.
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