arrow-fx-stm / arrow.fx.stm / STM / fold
open fun <A, B>
TArray
<A>.fold(init: B, f: (B, A) -> B): B
Fold a TArray to a single value.
import arrow.fx.stm.TArray
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tarr = TArray.new(size = 10, 2)
val result = atomically {
tarr.fold(0) { acc, v -> acc + v }
}
//sampleEnd
println("Result $result")
}
This function never retries.
Do you like Arrow?
✖