Created
August 5, 2017 23:51
-
-
Save aembleton/4fd177f8439ae1ce0b0ef9233391287b to your computer and use it in GitHub Desktop.
pmap extension for List
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
public fun <I,O> List<I>.pmap(transform: (I) -> O): List<O> { | |
val asyncOperations = this.map{wrapTransorm(transform, it)} | |
return runBlocking { asyncOperations.map { it.await() } } | |
} | |
fun <I,O> wrapTransorm(transform: (I) -> O, input:I) = async(CommonPool) {transform(input)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment