Let there is a function foo(): Int. For example, each call foo() returns different values. Just to illustrate:
var i: Int = 0 def foo(): Int = { i += 1 i } I would like to iterate through these values. Actually, I would like to construct an Iterator it so that each call it.next() computed by foo() called repeatedly. How it can be done?