Skip to content

Instantly share code, notes, and snippets.

@leopard627
Last active February 13, 2020 05:15
Show Gist options
  • Save leopard627/c42a0b8ddd7469abe2decbee0a4d573f to your computer and use it in GitHub Desktop.
Save leopard627/c42a0b8ddd7469abe2decbee0a4d573f to your computer and use it in GitHub Desktop.
map3.py
def myfunc_v1(func, *args):
for arg in zip(*args):
yield func(*arg)
def myfunc_v2(func, *args):
return (func(*arg) for arg in zip(*args))
print(list(myfunc_v1(abs, [1, 2, -3])))
print(list(myfunc_v2(abs, [1, 2, -3])))
assert list(myfunc_v1(abs, [1, 2, -3])) == list(myfunc_v2(abs, [1, 2, -3]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment