I have a Stream[A] and a function zeroOrMoreB(value: A): Seq[B] which given an A returns zero or more B. From these two pieces, how to I construct a Stream[B]?
I can get a Stream[Stream[B]] (see below), but I cannot figure out how to flatten it.
stream <- ZStream
.fromIterable(vectorOfAs)
.map(zeroOrMoreB)
As I always say, the Scaladoc is your friend.
You can use
mapConcatNow if
zeroOrMoreBactually returns a ZStream instead of a Seq, you just useflatMapFinally, if you like for syntax you can do this