arrow-fx-coroutines / arrow.fx.coroutines.stream / Stream / takeWhile
fun takeWhile(p: (O) ->
Boolean
):
Stream
<O>
Emits the longest prefix of the input for which all elements test true according to f.
import arrow.fx.coroutines.stream.*
//sampleStart
suspend fun main(): Unit =
Stream.range(0..1000)
.takeWhile { it != 5 }
.toList()
.let(::println) // [0, 1, 2, 3, 4]
//sampleEnd
Do you like Arrow?
✖