Can I copy the continuation object in kotlin?

I want to implement the “do comprehension for List” in kotlin, and I want to use suspend functions to do it for the compiler can automatically do the CPS transformation for me. But as I implement it, I found that I cannot find any way to copy a continuation object in kotlin …

So is there anyway to do it in kotlin?

Isn’t comprehension for list the same as map? In that case it seems that you want to write a parallel map, for a list, like this:

 suspend fun <A, B> Iterable<A>.parallelMap(f: suspend (A) -> B): List<B> = coroutineScope {
    map { async { f(it) } }.awaitAll()
}

About copying the continuation object, I’m not sure how’s that related to what you’re trying to do.