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

take

fun take(n: Int): Stream<O>

Emits the first n elements of this stream. Alias for take.

fun take(n: Long): Stream<O>

Emits the first n elements of this stream.

import arrow.fx.coroutines.stream.*

//sampleStart
suspend fun main(): Unit =
  Stream.range(0..1000)
    .take(5)
    .toList()
    .let(::println) // [0, 1, 2, 3, 4]
//sampleEnd

Do you like Arrow?

Arrow Org
<