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

repeatN

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

Repeat this stream a given number of times.

s.repeatN(n) == s ++ s ++ s ++ ... (n times)

import arrow.fx.coroutines.stream.*

//sampleStart
suspend fun main(): Unit =
  Stream(1,2,3)
    .repeatN(3)
    .toList()
    .let(::println) // [1, 2, 3, 1, 2, 3, 1, 2, 3]
//sampleEnd

Do you like Arrow?

Arrow Org
<