jorge-aranda
1/23/2019 - 10:14 PM

Methods to work fine with multiple repetitions of elements

Methods to work fine with multiple repetitions of elements


operator fun <T> T.times(times : Int) =
        sequenceOf(this).repeat().take(times)

operator fun <T> Sequence<T>.times(times : Int) =
        sequenceOf(this).repeat()
                .take(times)
                .flatMap { it }

// TODO pending "define" .repeat() method