I need to repeat a piece of code a maximum of n times, but terminate the loop once a condition is false, like in the following:
val runs = 100
var ctr = 0
var condition = true
while (ctr++ < runs && condition) {
//stuff and updates
}
Can this logic be stated more idiomatic, maybe with repeat?