Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)

Haskell Fizzbuzz!

By: GGMethos on Dec 21st, 2013  |  syntax: Haskell  |  size: 0.36 KB  |  hits: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. module Main where
  2.  
  3. main :: IO ()
  4. main = printAll $ map fizzBuzz [1..100]
  5.        where
  6.        printAll [] = return ()
  7.        printAll (x:xs) = putStrLn x >> printAll xs
  8.  
  9. fizzBuzz :: Integer -> String
  10. fizzBuzz n | n `mod` 15 == 0 = "FizzBuzz"
  11.            | n `mod` 5  == 0 = "Fizz"
  12.            | n `mod` 3  == 0 = "Buzz"
  13.            | otherwise       = show n