Skip to content

Instantly share code, notes, and snippets.

@marc-queiroz
Created March 1, 2020 19:55
Show Gist options
  • Save marc-queiroz/2910814d930c9b4e03c08a07f05710e7 to your computer and use it in GitHub Desktop.
Save marc-queiroz/2910814d930c9b4e03c08a07f05710e7 to your computer and use it in GitHub Desktop.
Python generator
funcs = [lambda x: x*x, lambda x: x+x]
arr = [1,2,3,4]
def generator():
for func in funcs:
yield func
for index, func in enumerate([[y for y in generator()] for x in generator()]):
arr = map(func[index], arr)
print('<generator object {}>'.format(list(arr)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment