6 ms·
> Consecutive calls to next() will always produce { done: true }. Not necessarily. You can make recursive generators which never "terminate". For example, here
by _xgw 8y ago
> Consecutive calls to next() will always produce { done: true }.
Not necessarily. You can make recursive generators which never "terminate". For example, here's a codegolfed version of a recursive generator which represents a n + 1 sequence:
p=function*a(x){yield x;yield*a(x+1)}(0)
- loige 8y agoI meant there "[Once the generator has completed], Consecutive calls to `next()` will always produce `{ done: true }`". I should probably make it more explicit PS: I like your n+1 example.