I am addicted to those
yield statements in python. If you’re in the same boat checkout PyGen. I know you can achieve the same thing with
Channels but its always felt a little clunky to me. Anyways, here is how it works:
julia> using PyGen julia> @pygen """ function fibonacci() n, m = 0, 1 while true yield m n, m = m, n + m end end """ fibonacci (generic function with 1 method) julia> for i in fibonacci() println(i) sleep(1) end 1 1 3 5 8 . . .