arrow-fx-coroutines / arrow.fx.coroutines.stream / Stream / effectScan

effectScan

fun <O2> effectScan(z: O2, f: suspend (O2, O) -> O2): Stream<O2>

Like scan, but accepts a suspending function.

import arrow.fx.coroutines.stream.*

//sampleStart
suspend fun main(): Unit =
  Stream(1,2,3,4)
  .effectScan(0) { acc,i -> acc + i }
  .toList()
  .let(::println) //[0, 1, 3, 6, 10]
//sampleEnd

Do you like Arrow?

Arrow Org
<