LoginSignup
0

More than 5 years have passed since last update.

HaskellでFizzBuzz

Posted at

とにかく動くコードを書くならPaizaという選択肢もあるんですが、
とりあえずFizzBuzzから始めてみました

ぶっちゃけ分からないことが多すぎるので当分は写経→本読んで内容を追っかける、がメインだろうなぁと思ってます

fizzbuzz.hs

fizzbuzz = map toFizzbuzz [1..] -- 無限リスト
  where
  toFizzbuzz x
    | x `mod` 15 == 0 = "FizzBuzz"
    | x `mod`  3 == 0 = "Fizz"
    | x `mod`  5 == 0 = "Buzz"
    | otherwise       = show x

main = mapM_ putStrLn $ take 10000 fizzbuzz

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0