Skip to content

Instantly share code, notes, and snippets.

@keita03301995
Created April 11, 2016 05:19
Show Gist options
  • Save keita03301995/e56571b3785e3fc85a82132b02b0b639 to your computer and use it in GitHub Desktop.
Save keita03301995/e56571b3785e3fc85a82132b02b0b639 to your computer and use it in GitHub Desktop.
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