Closed brianguenter closed 4 hours ago
Use @yieldfrom
not @yield
to nest them. I.e. you do not want to yield the entire iterator, rather you want each iteration to be its own yield.
julia> @resumable function f1(n)
for i in 1:n
@yield i
end
end
f1 (generic function with 1 method)
julia> @resumable function f2(n)
for i in 1:n
@yieldfrom f1(i)
end
end
f2 (generic function with 1 method)
julia> collect(f2(5))
15-element Vector{Any}:
1
1
2
1
2
Check this post stackoverflow post: https://stackoverflow.com/questions/9708902/in-practice-what-are-the-main-uses-for-the-yield-from-syntax-in-python-3-3
Nested resumable functions don't work the way I expected. The documentation doesn't have examples so it's not clear if this feature is even supported.
Minimal Working Example
When execute
for val in f2(10) println(val) end
expected to getInstead got this:
Package versions