Last active
December 10, 2015 14:49
-
-
Save jnjosh/4449693 to your computer and use it in GitHub Desktop.
Learning Haskell for fun. This gist is a log of changes I make to the fizzbuzz while learning. The revision history is the interesting part.
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
-- details: standard fizzbuzz, n % 3 = fizz, n % 5 = buzz, n % 15 = fizzbuzz | |
-- usage: ghci> fizzbuzz [1..100] | |
checkFizzbuzz :: Int -> String | |
checkFizzbuzz n | |
| mod n 15 == 0 = "fizzbuzz" | |
| mod n 5 == 0 = "buzz" | |
| mod n 3 == 0 = "fizz" | |
| otherwise = show n | |
fizzbuzz :: [Int] -> [String] | |
fizzbuzz nums = [ checkFizzbuzz n | n <- nums ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment