Read about iterator in [manual](https://nim-lang.github.io/Nim/manual.html#iterators-and-the-for-statement)
[playground](https://play.nim-lang.org/index.html?ix=1MaK) proc countTo(maxi: int): iterator(x = 1): int = result = iterator(x = 1): int = var i = 0 while i <= maxi: i.inc x yield i var itx3 = countTo 3 echo itx3(2) if not itx3.finished: echo itx3() Run
