Each callback should return the index from the iteration that created it. Find the bug.
kotlin
fun callbacks(): List<() -> Int> {
val result = mutableListOf<() -> Int>()
var index = 0
while (index < 3) {
result += { index }
index++
}
return result
}
fun main() {
println(callbacks().map { callback -> callback() })
}