Skip to content

Instantly share code, notes, and snippets.

@oluies
Created June 25, 2010 22:04
Show Gist options
  • Save oluies/453516 to your computer and use it in GitHub Desktop.
Save oluies/453516 to your computer and use it in GitHub Desktop.
val theRange = 1 to 100
def mapper(x:Int):String = {
require(x>0)
(x % 3, x % 5) match {
case (0,0) => "FizzBuzz"
case (0,_) => "Fizz"
case (_,0) => "Buzz"
case _ => x.toString
}
}
theRange.map{mapper(_)}.foreach(println)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment