arrow-fx-coroutines / arrow.fx.coroutines.stream / scan1

scan1

fun <O> Stream<O>.scan1(f: (O, O) -> O): Stream<O>

Like [scan], but uses the first element of the stream as the seed.

import arrow.fx.coroutines.stream.*

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

Do you like Arrow?

Arrow Org
<