Created
March 31, 2012 02:48
-
-
Save daiksy/2258828 to your computer and use it in GitHub Desktop.
素振り:scalaでfizzbuzz
This file contains hidden or 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
/** map **/ | |
1 to 100 map { | |
case i if i % 15 == 0 => "fizzbuzz" | |
case i if i % 3 == 0 => "fizz" | |
case i if i % 5 == 0 => "buzz" | |
case i => i | |
} foreach println | |
/** for **/ | |
for(i <- 1 to 100) println( | |
if (i % 15 == 0) "fizzbuzz" | |
else if (i % 3 == 0) "fizz" | |
else if (i % 5 == 0) "buzz" | |
else i | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment