Frage

Say, I have sequence of Enumerators, and the aim is to run them one by one, similar to long chain ofEnumerators with andThen between them, i.e. without interleaving.

So, how to combine Seq[Enumerator[T]] into Enumerator[T]?

War es hilfreich?

Lösung

Interesting, it seems that there is no built-in function for that. Something like that would work:

val enumerators: Seq[Enumerator[T]] = ...
enumerators.foldRight(Enumerator.eof[T])((st, i) => i andThen st)

Edit: update response after Andrew confirmed that it works.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top