Skip to content

Instantly share code, notes, and snippets.

@aembleton
Created August 5, 2017 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aembleton/4fd177f8439ae1ce0b0ef9233391287b to your computer and use it in GitHub Desktop.
Save aembleton/4fd177f8439ae1ce0b0ef9233391287b to your computer and use it in GitHub Desktop.
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