Is the following behaviour expected? I am trying to yield while iterating over a generator. Something like this, where 1:10 could be any iterator created with as_iterator().
library(coro)
g <- coro::generator(function() {
coro::iterate(for (x in 1:10) {
if (x < 5)
yield(x)
else
yield(-1)
})
})
g <- g()
g()
#> Error: `yield()` can't be called directly or within function arguments
Is the following behaviour expected? I am trying to
yield
while iterating over a generator. Something like this, where1:10
could be anyiterator
created withas_iterator()
.Created on 2020-11-16 by the reprex package (v0.3.0)