object StreamT extends StreamTInstances { | |
// 略 | |
def unfoldM[M[_],A,B](start: B)(f: B => M[Option[(A,B)]])(implicit M: Functor[M]): StreamT[M,A] = | |
StreamT[M,A](M.map(f(start)) { | |
case Some((a, b)) => Yield(a, unfoldM(b)(f)) | |
case None => Done | |
}) | |
def unfold[A,B](b: B)(f: B => Option[(A,B)]): StreamT[Id,A] = unfoldM[Id,A,B](b)(f) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment