を持っているとしIterator[A]
ます。scalaz streamに変換したいProcess[Nothing, A]
と思います。
import scalaz.stream._
def foo[A](it: Iterator[A]): Process[Nothing, A] = ???
どのように実装しfoo
ますか?
を持っているとしIterator[A]
ます。scalaz streamに変換したいProcess[Nothing, A]
と思います。
import scalaz.stream._
def foo[A](it: Iterator[A]): Process[Nothing, A] = ???
どのように実装しfoo
ますか?
私はあなたがそれを使用してそれを行うことができると思いますunfold
:
import scalaz.stream._
def foo[A](it: Iterator[A]): Process[Nothing, A] = Process.unfold(it) { it =>
if (it.hasNext) Some((it.next, it))
else None
}
例:
scala> foo(List(1,2,3,4,5).iterator).toList
res0: List[Int] = List(1,2,3,4,5)