Block as the third parameter
def zeno(start, stop)
distance = stop - start
travelled = start
while travelled < stop and distance > 0
yield travelled
distance = distance / 2.0
travelled += distance
end
end
steps = 0
zeno(0, 1) { steps += 1 }
steps # => 54
Related examples in the same category