Is there a package or language construct in R that facilitates or provides the implementation of "Python-like generators"?
By "Python-like generators" I mean functions that keep state between calls, in R syntax and borrowing the keyword yield from Python will be something like:
iterable.fun <- function(){
yield list('a','b','c')
}
With yield instead of a return, then calling the function three consecutive times would give:
> iterable.fun()
'a'
> iterable.fun()
'b'
> iterable.fun()
'c'
Edit: I left out an aspect of Python generators that makes them different from iterators. It is that the whole list of objects to iterate on is not built on the first call and then iterated, but each function call creates the one element that will return for that call.