Created
November 1, 2016 21:16
-
-
Save anonymous/de3539ad014de2b18c2fc46a4aff946f 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 parallelPaper(lines: List[String]): Int = { | |
val futures: List[Future[Int]] = for (line <- lines) yield parallelCompute(line) | |
val result = futures.foldLeft(0) { (total, future) => | |
{ | |
future.onComplete { | |
case Success(value) => { | |
total + value | |
} | |
case Failure(e) => e.printStackTrace() | |
} | |
total | |
} | |
} | |
Thread.sleep(1000) | |
result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment