Created
December 14, 2011 11:12
-
-
Save omegatakuma/1476167 to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ - if分はスマートに書けねえ・・。 | |
そんなスマートじゃなくてすいません。 - } | |
num x = do | |
if x `mod` 3 == 0 | |
then "fizz" | |
else if x `mod` 5 == 0 | |
then "buzz" | |
else if x `mod` 15 == 0 | |
then "fizzbuzz" | |
else show x | |
fizzbuzz list = unwords $ map num list | |
main = do | |
putStrLn $ fizzbuzz[1..100] | |
{- ガード条件で書いた方がいいことに気づきました。 | |
ははは。ふぁぼ -} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment