All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.Repeat.kt Maven / Gradle / Ivy

There is a newer version: 8.0.0
Show newest version
package com.juul.tuulbox.functional

/** Returns a function that repeats the application of [this] [count] times. */
public fun  ((T) -> T).repeat(count: Int): (T) -> T {
    require(count >= 0) { "Repeat `count` must not be negative." }
    return { initialValue ->
        var value = initialValue
        kotlin.repeat(count) {
            value = this(value)
        }
        value
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy