Skip to content

Instantly share code, notes, and snippets.

@dhilst
Last active March 22, 2022 02:46
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 dhilst/ff2e51f3014bf9d58e6dd66b75fdfa55 to your computer and use it in GitHub Desktop.
Save dhilst/ff2e51f3014bf9d58e6dd66b75fdfa55 to your computer and use it in GitHub Desktop.
generators as functions
def gen(start, f):
return lambda: (start, gen(f(start), f))
def inc(a):
return a + 1
g = gen(0, inc)
while True:
x, g = g()
print(x)
if x == 11:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment