Created
September 21, 2017 07:33
-
-
Save kareblak/6a0dc9f9c044b04d9bc082c37143831d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lastB[A, B](implicit S:Strategy): Pipe2[Task, A, B, (A, B)] = (as, bs) => | |
bs.uncons1.flatMap { | |
case None => Stream.empty | |
case Some((init, newBs)) => | |
as.either(newBs).mapAccumulate(init) { | |
case (b, Left(a)) => (b, Some(a)) | |
case (_, Right(b)) => (b, None) | |
}.collect { case (b, Some(a)) => (a, b) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment