Skip to content

Instantly share code, notes, and snippets.

@justinhj
Created July 15, 2019 17:07
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 justinhj/952b12b33acc2ea65be69037ac19050f to your computer and use it in GitHub Desktop.
Save justinhj/952b12b33acc2ea65be69037ac19050f to your computer and use it in GitHub Desktop.
Another fizz buzz
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