Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fizz buzz as FS2 streams
val fb = Stream.emits(List(false, false, true)).repeat.zip(Stream.emits(List(false,false,false,false,true)).repeat).map{
case (true,true) => "fizzbuzz"
case (true,false) => "fizz"
case (false,true) => "buzz"
case (false,false) => ""
}
//fb: Stream[Nothing, String] = Stream(..)
// @ fb.take(30).toList
// res27: List[String] = List(
// "",
// "",
// "fizz",
// "",
// "buzz",
// "fizz",
// "",
// "",
// "fizz",
// "buzz",
// "",
// "fizz",
// "",
// "",
// "fizzbuzz",
// "",
// "",
// "fizz",
// "",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.