Task

Write a procedure which accepts as arguments another procedure and a positive integer.

The latter procedure is executed a number of times equal to the accepted integer.




// version 1.0.6
 
fun repeat(n: Int, f: () -> Unit) {
    for (i in 1..n) {
        f()
        println(i)
    }
}
 
fun main(args: Array<String>) {
    repeat(5) { print("Example ") }
}