arrow-fx-coroutines / arrow.fx.coroutines / parMapN

parMapN

suspend inline fun <A, B, C> ~~parMapN~~(crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline f: suspend (A, B) -> C): C Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    { "First one is on ${Thread.currentThread().name}" },
    { "Second one is on ${Thread.currentThread().name}" }
  ) { a, b ->
      "$a\n$b"
    }
  //sampleEnd
 println(result)
}

Parameters

fa - value to parallel map

fb - value to parallel map

f - function to map/combine value A and B

See Also

parMapN

suspend inline fun <A, B, C> ~~parMapN~~(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline f: suspend (A, B) -> C): C Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    Dispatchers.IO,
    { "First one is on ${Thread.currentThread().name}" },
    { "Second one is on ${Thread.currentThread().name}" }
  ) { a, b ->
      "$a\n$b"
    }
  //sampleEnd
 println(result)
}

Parameters

fa - value to parallel map

fb - value to parallel map

f - function to map/combine value A and B

See Also

parMapN

suspend inline fun <A, B, C, D> ~~parMapN~~(crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline f: suspend (A, B, C) -> D): D Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    { "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)
}

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

See Also

parMapN

suspend inline fun <A, B, C, D> ~~parMapN~~(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline f: suspend (A, B, C) -> D): D Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    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)
}

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.

See Also

parMapN

suspend inline fun <A, B, C, D, E> ~~parMapN~~(crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline f: suspend (A, B, C, D) -> E): E Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    { "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)
}

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

See Also

parMapN

suspend inline fun <A, B, C, D, E> ~~parMapN~~(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline f: suspend (A, B, C, D) -> E): E Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    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)
}

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.

See Also

parMapN

suspend inline fun <A, B, C, D, E, F> ~~parMapN~~(crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline fe: suspend () -> E, crossinline f: suspend (A, B, C, D, E) -> F): F Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    { "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)
}

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

See Also

parMapN

suspend inline fun <A, B, C, D, E, F> ~~parMapN~~(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline fe: suspend () -> E, crossinline f: suspend (A, B, C, D, E) -> F): F Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    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)
}

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.

See Also

parMapN

suspend inline fun <A, B, C, D, E, F, G> ~~parMapN~~(crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline fe: suspend () -> E, crossinline ff: suspend () -> F, crossinline f: suspend (A, B, C, D, E, F) -> G): G Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    { "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)
}

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

See Also

parMapN

suspend inline fun <A, B, C, D, E, F, G> ~~parMapN~~(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline fe: suspend () -> E, crossinline ff: suspend () -> F, crossinline f: suspend (A, B, C, D, E, F) -> G): G Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    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)
}

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

See Also

parMapN

suspend inline fun <A, B, C, D, E, F, G, H> ~~parMapN~~(crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline fe: suspend () -> E, crossinline ff: suspend () -> F, crossinline fg: suspend () -> G, crossinline f: suspend (A, B, C, D, E, F, G) -> H): H Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    { "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)
}

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

See Also

parMapN

suspend inline fun <A, B, C, D, E, F, G, H> ~~parMapN~~(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline fe: suspend () -> E, crossinline ff: suspend () -> F, crossinline fg: suspend () -> G, crossinline f: suspend (A, B, C, D, E, F, G) -> H): H Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    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)
}

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

See Also

parMapN

suspend inline fun <A, B, C, D, E, F, G, H, I> ~~parMapN~~(crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline fe: suspend () -> E, crossinline ff: suspend () -> F, crossinline fg: suspend () -> G, crossinline fh: suspend () -> H, crossinline f: suspend (A, B, C, D, E, F, G, H) -> I): I Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    { "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)
}

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

See Also

parMapN

suspend inline fun <A, B, C, D, E, F, G, H, I> ~~parMapN~~(ctx: CoroutineContext = EmptyCoroutineContext, crossinline fa: suspend () -> A, crossinline fb: suspend () -> B, crossinline fc: suspend () -> C, crossinline fd: suspend () -> D, crossinline fe: suspend () -> E, crossinline ff: suspend () -> F, crossinline fg: suspend () -> G, crossinline fh: suspend () -> H, crossinline f: suspend (A, B, C, D, E, F, G, H) -> I): I Deprecated: parMapN has been deprecated in favor of parZip with CoroutineScope enabled lambdas

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 = parMapN(
    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)
}

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

See Also

parMapN

Do you like Arrow?

Arrow Org
<