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

constant

fun <O> constant(o: O, chunkSize: Int = 256): Stream<O>

Creates an infinite pure stream that always returns the supplied value.

Elements are emitted in finite chunks with chunkSize number of elements.

import arrow.fx.coroutines.stream.*

//sampleEnd
suspend fun main(): Unit {
  Stream.constant(0)
    .take(5)
    .toList()
    .let(::println) // [0, 0, 0, 0, 0]
}
//sampleStart

Do you like Arrow?

Arrow Org
<