gouf
3/7/2014 - 5:15 PM

Haskell でFizzBuzz Ref: http://www.geocities.jp/m_hiroi/func/haskell.html#begin

toStr :: Int -> String
toStr x = if x `mod` 15 == 0 then "FizzBuzz"
          else if x `mod` 3 == 0 then "Fizz"
          else if x `mod` 5 == 0 then "Buzz"
          else show x
fizzbuzz :: Int -> [String]
fizzbuzz n = map toStr[1 .. n]

main = do
  print (fizzbuzz 15)

-- output: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]