Skip to content

Instantly share code, notes, and snippets.

@Spuffynism
Last active July 7, 2018 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Spuffynism/0e92acc457affc1f46b4e455e5274712 to your computer and use it in GitHub Desktop.
Save Spuffynism/0e92acc457affc1f46b4e455e5274712 to your computer and use it in GitHub Desktop.
Codegolfing generators
// recursive infinite generator
p=function*a(x){yield x;yield*a(x+1)}(0)
o={*a(x){yield x;yield*this.a(x+1)}}.a(0)
// using iterators
q=(x=>({next:_=>({value:x++})}))(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment