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

takeLast

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

Emits the last n elements of the input.

import arrow.fx.coroutines.stream.*

//sampleStart
suspend fun main(): Unit =
  Stream.range(0..1000)
    .takeLast(5)
    .toList()
    .let(::println) // [996, 997, 998, 999, 1000]
//sampleEnd

Do you like Arrow?

Arrow Org
<