As I always say, the Scaladoc is your friend.

You can use mapConcat

val stream = ZStream.fromIterable(vectorOfAs).mapConcat(zeroOrMoreB)

Now if zeroOrMoreB actually returns a ZStream instead of a Seq, you just use flatMap

val stream = ZStream.fromIterable(vectorOfAs).flatMap(zeroOrMoreB)

Finally, if you like for syntax you can do this

val stream = for {
  a <- ZStream.fromIterable(vectorOfAs)
  b <- ZStream.fromIterable(zeroOrMoreB(a))
} yield b

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top