parZip

inline suspend fun <A, B, C> parZip(    crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline f: suspend CoroutineScope.(A, B) -> C): C

Runs fa, fb in parallel on Dispatchers.Default and combines their results using the provided function.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
//sampleStart
val result = parZip(
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" }
) { a, b ->
"$a\n$b"
}
//sampleEnd
println(result)
}

See also

for a function that can run on any CoroutineContext

Parameters

fa

value to parallel map

fb

value to parallel map

f

function to map/combine value A and B


inline suspend fun <A, B, C> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline f: suspend CoroutineScope.(A, B) -> C): C

Runs fa, fb in parallel on ctx and combines their results using the provided function.

Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with ctx argument. If the combined context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. WARNING If the combined context has a single threaded ContinuationInterceptor, this function will not run fa, fb in parallel.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parZip(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" }
) { a, b ->
"$a\n$b"
}
//sampleEnd
println(result)
}

See also

for a function that ensures operations run in parallel on the Dispatchers.Default.

Parameters

fa

value to parallel map

fb

value to parallel map

f

function to map/combine value A and B


inline suspend fun <A, B, C, D> parZip(    crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline f: suspend CoroutineScope.(A, B, C) -> D): D

Runs fa, fb, fc in parallel on Dispatchers.Default and combines their results using the provided function.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
//sampleStart
val result = parZip(
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" }
) { a, b, c ->
"$a\n$b\n$c"
}
//sampleEnd
println(result)
}

See also

for a function that can run on any CoroutineContext.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

f

function to map/combine value A, B and C


inline suspend fun <A, B, C, D> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline f: suspend CoroutineScope.(A, B, C) -> D): D

Runs fa, fb, fc in parallel on ctx and combines their results using the provided function.

Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with ctx argument. If the combined context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. WARNING If the combined context has a single threaded ContinuationInterceptor, this function will not run fa, fb&fc in parallel.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parZip(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" }
) { a, b, c ->
"$a\n$b\n$c"
}
//sampleEnd
println(result)
}

See also

for a function that ensures operations run in parallel on the Dispatchers.Default.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

f

function to map/combine value A, B and C.


inline suspend fun <A, B, C, D, E> parZip(    crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline f: suspend CoroutineScope.(A, B, C, D) -> E): E

Runs fa, fb, fc, fd in parallel on Dispatchers.Default and combines their results using the provided function.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
//sampleStart
val result = parZip(
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" }
) { a, b, c, d ->
"$a\n$b\n$c\n$d"
}
//sampleEnd
println(result)
}

See also

for a function that can run on any CoroutineContext.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

f

function to map/combine value A, B, C and D


inline suspend fun <A, B, C, D, E> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline f: suspend CoroutineScope.(A, B, C, D) -> E): E

Runs fa, fb, fc, fd in parallel on ctx and combines their results using the provided function.

Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with ctx argument. If the combined context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. WARNING If the combined context has a single threaded ContinuationInterceptor, this function will not run fa, fb, fc&fd in parallel.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parZip(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" }
) { a, b, c, d ->
"$a\n$b\n$c\n$d"
}
//sampleEnd
println(result)
}

See also

for a function that ensures operations run in parallel on the Dispatchers.Default.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

f

function to map/combine value A, B, C and D.


inline suspend fun <A, B, C, D, E, F> parZip(    crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline fe: suspend CoroutineScope.() -> E,     crossinline f: suspend CoroutineScope.(A, B, C, D, E) -> F): F

Runs fa, fb, fc, fd, fe in parallel on Dispatchers.Default and combines their results using the provided function.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
//sampleStart
val result = parZip(
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" }
) { a, b, c, d, e ->
"$a\n$b\n$c\n$d\n$e"
}
//sampleEnd
println(result)
}

See also

for a function that can run on any CoroutineContext.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

fe

value to parallel map

f

function to map/combine value A, B, C, D and E


inline suspend fun <A, B, C, D, E, F> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline fe: suspend CoroutineScope.() -> E,     crossinline f: suspend CoroutineScope.(A, B, C, D, E) -> F): F

Runs fa, fb, fc, fd, fe in parallel on ctx and combines their results using the provided function.

Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with ctx argument. If the combined context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. WARNING If the combined context has a single threaded ContinuationInterceptor, this function will not run fa, fb, fc, fd&fe in parallel.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parZip(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" }
) { a, b, c, d, e ->
"$a\n$b\n$c\n$d\n$e"
}
//sampleEnd
println(result)
}

See also

for a function that ensures operations run in parallel on the Dispatchers.Default.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

fe

value to parallel map

f

function to map/combine value A, B, C, D, and E.


inline suspend fun <A, B, C, D, E, F, G> parZip(    crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline fe: suspend CoroutineScope.() -> E,     crossinline ff: suspend CoroutineScope.() -> F,     crossinline f: suspend CoroutineScope.(A, B, C, D, E, F) -> G): G

Runs fa, fb, fc, fd, fe, ff in parallel on Dispatchers.Default and combines their results using the provided function.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
//sampleStart
val result = parZip(
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" }
) { a, b, c, d, e, f ->
"$a\n$b\n$c\n$d\n$e\n$f"
}
//sampleEnd
println(result)
}

See also

for a function that can run on any CoroutineContext.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

fe

value to parallel map

ff

value to parallel map

f

function to map/combine value A, B, C, D, E and F


inline suspend fun <A, B, C, D, E, F, G> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline fe: suspend CoroutineScope.() -> E,     crossinline ff: suspend CoroutineScope.() -> F,     crossinline f: suspend CoroutineScope.(A, B, C, D, E, F) -> G): G

Runs fa, fb, fc, fd, fe, ff in parallel on ctx and combines their results using the provided function.

Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with ctx argument. If the combined context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. WARNING If the combined context has a single threaded ContinuationInterceptor, this function will not run fa, fb, fc, fd, fe&ff in parallel.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parZip(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" }
) { a, b, c, d, e, g ->
"$a\n$b\n$c\n$d\n$e\n$g"
}
//sampleEnd
println(result)
}

See also

for a function that ensures operations run in parallel on the Dispatchers.Default.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

fe

value to parallel map

ff

value to parallel map

f

function to map/combine value A, B, C, D, E and F


inline suspend fun <A, B, C, D, E, F, G, H> parZip(    crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline fe: suspend CoroutineScope.() -> E,     crossinline ff: suspend CoroutineScope.() -> F,     crossinline fg: suspend CoroutineScope.() -> G,     crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G) -> H): H

Runs fa, fb, fc, fd, fe, ff, fg in parallel on Dispatchers.Default and combines their results using the provided function.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
//sampleStart
val result = parZip(
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" },
{ "Seventh one is on ${Thread.currentThread().name}" }
) { a, b, c, d, e, g, h ->
"$a\n$b\n$c\n$d\n$e\n$g\n$h"
}
//sampleEnd
println(result)
}

See also

for a function that can run on any CoroutineContext.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

fe

value to parallel map

ff

value to parallel map

fg

value to parallel map

f

function to map/combine value A, B, C, D, E, F and G


inline suspend fun <A, B, C, D, E, F, G, H> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline fe: suspend CoroutineScope.() -> E,     crossinline ff: suspend CoroutineScope.() -> F,     crossinline fg: suspend CoroutineScope.() -> G,     crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G) -> H): H

Runs fa, fb, fc, fd, fe, ff, fg in parallel on ctx and combines their results using the provided function.

Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with ctx argument. If the combined context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. WARNING If the combined context has a single threaded ContinuationInterceptor, this function will not run fa, fb, fc, fd, fe, ff&fg in parallel.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parZip(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" },
{ "Seventh one is on ${Thread.currentThread().name}" }
) { a, b, c, d, e, f, g ->
"$a\n$b\n$c\n$d\n$e\n$f\n$g"
}
//sampleEnd
println(result)
}

See also

for a function that ensures operations run in parallel on the Dispatchers.Default.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

fe

value to parallel map

ff

value to parallel map

fg

value to parallel map

f

function to map/combine value A, B, C, D, E, F and G


inline suspend fun <A, B, C, D, E, F, G, H, I> parZip(    crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline fe: suspend CoroutineScope.() -> E,     crossinline ff: suspend CoroutineScope.() -> F,     crossinline fg: suspend CoroutineScope.() -> G,     crossinline fh: suspend CoroutineScope.() -> H,     crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G, H) -> I): I

Runs fa, fb, fc, fd, fe, ff, fg, fh in parallel on Dispatchers.Default and combines their results using the provided function.

import arrow.fx.coroutines.*

suspend fun main(): Unit {
//sampleStart
val result = parZip(
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" },
{ "Seventh one is on ${Thread.currentThread().name}" },
{ "Eighth one is on ${Thread.currentThread().name}" }
) { a, b, c, d, e, f, g, h ->
"$a\n$b\n$c\n$d\n$e\n$f\n$g\n$h"
}
//sampleEnd
println(result)
}

See also

for a function that can run on any CoroutineContext.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

fe

value to parallel map

ff

value to parallel map

fg

value to parallel map

fh

value to parallel map

f

function to map/combine value A, B, C, D, E, F, G and H


inline suspend fun <A, B, C, D, E, F, G, H, I> parZip(    ctx: CoroutineContext = EmptyCoroutineContext,     crossinline fa: suspend CoroutineScope.() -> A,     crossinline fb: suspend CoroutineScope.() -> B,     crossinline fc: suspend CoroutineScope.() -> C,     crossinline fd: suspend CoroutineScope.() -> D,     crossinline fe: suspend CoroutineScope.() -> E,     crossinline ff: suspend CoroutineScope.() -> F,     crossinline fg: suspend CoroutineScope.() -> G,     crossinline fh: suspend CoroutineScope.() -> H,     crossinline f: suspend CoroutineScope.(A, B, C, D, E, F, G, H) -> I): I

Runs fa, fb, fc, fd, fe, ff, fg, fh in parallel on ctx and combines their results using the provided function.

Coroutine context is inherited from a CoroutineScope, additional context elements can be specified with ctx argument. If the combined context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. WARNING If the combined context has a single threaded ContinuationInterceptor, this function will not run fa, fb, fc, fd, fe, ff&fg in parallel.

import arrow.fx.coroutines.*
import kotlinx.coroutines.Dispatchers

suspend fun main(): Unit {
//sampleStart
val result = parZip(
Dispatchers.IO,
{ "First one is on ${Thread.currentThread().name}" },
{ "Second one is on ${Thread.currentThread().name}" },
{ "Third one is on ${Thread.currentThread().name}" },
{ "Fourth one is on ${Thread.currentThread().name}" },
{ "Fifth one is on ${Thread.currentThread().name}" },
{ "Sixth one is on ${Thread.currentThread().name}" },
{ "Seventh one is on ${Thread.currentThread().name}" }
) { a, b, c, d, e, f, g ->
"$a\n$b\n$c\n$d\n$e\n$f\n$g"
}
//sampleEnd
println(result)
}

See also

for a function that ensures operations run in parallel on the Dispatchers.Default.

Parameters

fa

value to parallel map

fb

value to parallel map

fc

value to parallel map

fd

value to parallel map

fe

value to parallel map

ff

value to parallel map

fg

value to parallel map

fh

value to parallel map

f

function to map/combine value A, B, C, D, E, F, G and H