Skip to content

Instantly share code, notes, and snippets.

@akitotakeki
Last active February 3, 2017 14:53
Show Gist options
  • Save akitotakeki/4cca4287d418fdec757cbf3e76377360 to your computer and use it in GitHub Desktop.
Save akitotakeki/4cca4287d418fdec757cbf3e76377360 to your computer and use it in GitHub Desktop.
def square_gen(num):
for i in range(num):
yield i**2
gen = square_gen(5)
for i in gen:
print(i)
for i in map(lambda x: x**2, range(5)):
print(i)
squares = (x ** 2 for x in range(5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment