Skip to content

Instantly share code, notes, and snippets.

@apauley
Created March 22, 2015 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apauley/ca8197f5b9b822097c50 to your computer and use it in GitHub Desktop.
Save apauley/ca8197f5b9b822097c50 to your computer and use it in GitHub Desktop.
import scalaz._
import Scalaz._
object FizzBuzz {
def fizz(n: Int): Option[String] = if (n % 3 == 0) some("fizz") else None
def buzz(n: Int): Option[String] = if (n % 5 == 0) Some("buzz") else None
def fizzbuzz(n: Int): String = (fizz(n) |+| buzz(n)).getOrElse(n.toString)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment