Created
August 4, 2013 08:55
-
-
Save kishida/6149770 to your computer and use it in GitHub Desktop.
fizzbuzz with Haskell
This file contains hidden or 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
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