Created
December 9, 2014 14:57
-
-
Save orionll/e367364c0ca2cf92ad11 to your computer and use it in GitHub Desktop.
FizzBuzz implementation with Scalaz
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
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