Skip to content

Instantly share code, notes, and snippets.

View diegovar's full-sized avatar

Diego Varese diegovar

View GitHub Profile
@diegovar
diegovar / linearize.scala
Created August 16, 2012 17:44 — forked from viktorklang/linearize.scala
A Linearized version of Sequence
import scala.concurrent._
import scala.collection.mutable.Builder
import scala.collection.generic.CanBuildFrom
import language.higherKinds
/**
* Linearize asynchrnously applies a given function in-order to a sequence of values, producing a Future with the result of the function applications.
* Execution of subsequent entries will be aborted if an exception is thrown in the application of the function.
*/
def linearize[T, U, C[T] <: Traversable[T]](s: C[T])(f: T => U)(implicit cbf: CanBuildFrom[C[T], U, C[U]], e: ExecutionContext): Future[C[U]] = {