The following command emits the next Fibonacci number each time it is called. ====== proc f {} { yield [set a 0] yield [set b 1] while 1 { yield [set a [expr {$a + $b}]] lassign [list $b $a] a b } } coroutine fib f ====== The call to `[coroutine]` is considered to be fib(0) and returns 0. Add a nullary `[yield]` before the first `yield` to make the first call to `fib` the zeroth call. <>Mathematics