Created
July 15, 2019 17:07
-
-
Save justinhj/952b12b33acc2ea65be69037ac19050f to your computer and use it in GitHub Desktop.
Another fizz buzz
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 fs2._ | |
import cats._ | |
import cats.implicits._ | |
object Fs2FizzBuzz { | |
val fb = Stream.emits(List(None, None, "Fizz".some)). | |
repeat. | |
zip(Stream.emits(List(None, None, None, None, "Buzz".some)). | |
repeat). | |
map{ | |
case (a,b) => | |
a |+| b | |
} | |
def run(n: Int) = fb[IO].map{ | |
case Some(a) => println(a) | |
case _ => | |
}.take(n). | |
compile. | |
drain. | |
unsafeRunSync | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment