Very lightweight, task-based generators.
#
Generators.generate
— Method.
generate(func::Function)
Create a generator from func. Func receives a "yield" function as its argument. You can use this function to produce values.
Here's an example of a recursive generator:
flattened(list) = generate() do yield
fl(el::Vector) = foreach(fl, el)
fl(el) = yield(el)
fl(list)
end
[flattened([1, [2, [3], 4], 5])...] == [1,2,3,4,5]