Created
August 23, 2016 14:09
-
-
Save atamborrino/61afee05b81ab5823078a2b608a5555e to your computer and use it in GitHub Desktop.
Sequential traverse
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 sequentialTraverse[A, B](as: Seq[A])(f: A => Future[B]): Future[Seq[B]] = { | |
| as.foldLeft(Future.sucessful(Vector.empty[B])) { (futAcc, a) => | |
| for { | |
| acc <- futAcc | |
| b <- f(a) | |
| } yield acc :+ b | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment