Created
October 30, 2014 12:18
-
-
Save purcell/991605f16bd08f2cc4a0 to your computer and use it in GitHub Desktop.
fizzbuzz
This file contains 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
module FizzBuzz where | |
fizzbuzz :: (Show a, Integral a) => a -> String | |
fizzbuzz n = case (n `rem` 3, n `rem` 5) of | |
(0, 0) -> "FizzBuzz" | |
(0, _) -> "Fizz" | |
(_, 0) -> "Buzz" | |
_ -> show n | |
main = mapM_ (putStrLn . fizzbuzz) [1..50] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This simplest-thing-that-could-possibly-work code is most likely how I'd actually solve fizzbuzz in haskell.