commonMain.Repeat.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functional-jvm Show documentation
Show all versions of functional-jvm Show documentation
Toolbox of utilities/helpers for Kotlin development
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