Advertisement
qwertypoops

Untitled

Aug 5th, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.29 KB | None | 0 0
  1. def all[T, C[X] <: Traversable[X]](fs: C[Future[T]])(implicit cbf: CanBuildFrom[C[T], T, C[T]], ec: ExecutionContext): Future[C[T]] = {
  2.  val b = cbf()
  3.  val p = Promise[b.type]()
  4.  p.success(b)
  5.  fs.foldLeft(p.future) { (acc, f) =>
  6.    for { x <- f; b <- acc } yield b += x
  7.  } map { _.result() }
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement