Skip to content

Instantly share code, notes, and snippets.

@tamasd
Created July 30, 2013 18:20
Show Gist options
  • Save tamasd/6115421 to your computer and use it in GitHub Desktop.
Save tamasd/6115421 to your computer and use it in GitHub Desktop.
import Prelude
fizzbuzz :: (Eq a, Num a) => a -> a -> [Char] -> [Char]
fizzbuzz 0 0 _ = "FizzBuzz"
fizzbuzz 0 _ _ = "Fizz"
fizzbuzz _ 0 _ = "Buzz"
fizzbuzz _ _ x = x
checkfb :: (Show a, Integral a) => a -> [Char]
checkfb n = fizzbuzz (n `rem` 3) (n `rem` 5) (show n)
main :: IO ()
main = mapM_ putStrLn $ map checkfb [1..100]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment