Skip to content

Instantly share code, notes, and snippets.

@jnjosh
Last active December 10, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnjosh/4449693 to your computer and use it in GitHub Desktop.
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.
-- 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