Skip to content

Instantly share code, notes, and snippets.

@orionll
Created December 9, 2014 14:57
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 orionll/e367364c0ca2cf92ad11 to your computer and use it in GitHub Desktop.
Save orionll/e367364c0ca2cf92ad11 to your computer and use it in GitHub Desktop.
FizzBuzz implementation with Scalaz
import scalaz.Applicative
import scalaz.syntax.enum._
import scalaz.syntax.show._
import scalaz.std.anyVal._
import scalaz.effect.IO
import scalaz.effect.IO._
object Main extends App {
def fizzBuzz(i: Int): String = if (i % 3 === 0 && i % 5 === 0) "FizzBuzz"
else if (i % 3 === 0) "Fizz"
else if (i % 5 === 0) "Buzz"
else i.shows
val io = Applicative[IO].sequence((1 |=> 100) map fizzBuzz map putStrLn)
io.unsafePerformIO()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment