Skip to content

Instantly share code, notes, and snippets.

@haiiro-shimeji
Last active December 11, 2015 04:48
Show Gist options
  • Select an option

  • Save haiiro-shimeji/4547794 to your computer and use it in GitHub Desktop.

Select an option

Save haiiro-shimeji/4547794 to your computer and use it in GitHub Desktop.
import System.Environment
fizzbuzz n
| 0 >= n = error "n must be >0."
| otherwise =
let fb x
| 0 == mod x 15 = "FizzBuzz"
| 0 == mod x 5 = "Buzz"
| 0 == mod x 3 = "Fizz"
| otherwise = show x
in [ fb x | x <- [1..n] ]
main = do
args <- getArgs
mapM putStrLn $ fizzbuzz (read (head args) ::Int)
main = putStrLn "hello, world."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment