Last active
February 13, 2020 05:15
-
-
Save leopard627/c42a0b8ddd7469abe2decbee0a4d573f to your computer and use it in GitHub Desktop.
map3.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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