Skip to content

Instantly share code, notes, and snippets.

@kishida
Created August 4, 2013 08:55
Show Gist options
  • Save kishida/6149770 to your computer and use it in GitHub Desktop.
Save kishida/6149770 to your computer and use it in GitHub Desktop.
fizzbuzz with Haskell
fizzbuzz :: Integer -> [String]
fizzbuzz x = reverse $ impl x
where
impl :: Integer -> [String]
impl 0 = []
impl n
| n `mod` 15 == 0 = "fizzbuzz" : next
| n `mod` 3 == 0 = "fizz" : next
| n `mod` 5 == 0 = "buzz" : next
| otherwise = show n : next
where next = impl $ n - 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment