Created
April 28, 2018 19:36
-
-
Save gclaramunt/a40783e1f1c835a38c7ae2569abd8d3f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sequence[A, B](l: Iterable[A])(fn: A ⇒ Future[B])(implicit ec: ExecutionContext): Future[List[B]] = | |
l.foldLeft(Future(List.empty[B])) { | |
(previousFuture, next) ⇒ | |
for { | |
previousResults ← previousFuture | |
next ← fn(next) | |
} yield previousResults :+ next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment