Skip to content

Instantly share code, notes, and snippets.

@dan5
Created February 5, 2011 10:42
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 dan5/812360 to your computer and use it in GitHub Desktop.
Save dan5/812360 to your computer and use it in GitHub Desktop.
Haskellでプログラムを書く勉強会#0の成果
main = putStrLn $ concat $ map addln $ map fizzbuzz [1..20]
addln str = concat [str, "\n"]
fizzbuzz a = if (a `mod` 3) == 0 then "fizz"
else if (a `mod` 5) == 0 then "buzz"
else show a
main = putStrLn $ concat $ map addln $ map fizzbuzz [1..20]
addln str = concat [str, "\n"]
fizzbuzz a | (a `mod` 15) == 0 = "fizz buzz"
| (a `mod` 3) == 0 = "buzz"
| (a `mod` 5) == 0 = "buzz"
| otherwise = show a
import System
main = do
args <- getArgs
putStrLn $ unlines $ fizzbuzz (read $ head args)
fizzbuzz n = map _fizzbuzz [1..n]
_fizzbuzz a | (a `mod` 15) == 0 = "fizz buzz"
| (a `mod` 3) == 0 = "buzz"
| (a `mod` 5) == 0 = "buzz"
| otherwise = show a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment