arrow-fx-coroutines / arrow.fx.coroutines.stream / Stream / zipWithScan1
fun <B> zipWithScan1(z: B, f: (B, O) -> B):
Stream
<
Pair
<O, B>>
Zips the input with a running total according to S
, including the current element. Thus the initial
z
value is the first emitted to the output:
import arrow.fx.coroutines.stream.*
//sampleStart
suspend fun main(): Unit =
Stream("uno", "dos", "tres", "cuatro")
.zipWithScan1(0) { acc, b -> acc + b.length }
.toList()
.let(::println) //[(uno,3), (dos,6), (tres,10), (cuatro,16)]
//sampleEnd
See Also
Do you like Arrow?
✖