You can either make an iterator, i.e. define Base.iterate
for a suitable struct
, as in Interfaces · The Julia Language, With less boilerplate you can make a coroutine with the help of a Channel
, as in Asynchronous Programming · The Julia Language. Instead of yield
in the loop, you do a put!
on a channel, which you can take!
from elsewhere.
2 Likes