Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pmap extension for List
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
You can’t perform that action at this time.