If I have a `List<A>` and a fn `suspend (A) ...
# coroutines
g
If I have a
List<A>
and a fn
suspend (A) -> B
, how can I apply this fn on the list in parallel?
t
Copy code
coroutineScope {
  list.map {
    async { transform(it) }
  }.awaitAll()
}
Is one way to do it.
n
I would agree with Thibault in high latency operations (file reading, network) but I'm a simple transform, if try to avoid coroutines altogether
a
would a
Copy code
list.asFlow().collect { mySuspendingFunction(it) }
work in this case?
j
@Andrea Giuliano that would be processed sequentially, though, not in parallel
👍 1