Created
April 11, 2016 05:19
-
-
Save keita03301995/e56571b3785e3fc85a82132b02b0b639 to your computer and use it in GitHub Desktop.
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
object FizzBuzz { | |
def main(args:Array[String]) = { | |
val list = (1 to 100) | |
val fizzbuzz = (x: Int) => (x%3, x%5) match { | |
case (0, 0) => "FizzBuzz" | |
case (0, _) => "Fizz" | |
case (_, 0) => "Buzz" | |
case _ => x.toString | |
} | |
val result = list.map(fizzbuzz).mkString(",") | |
println(result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment