Skip to content

Instantly share code, notes, and snippets.

@sooop
Created May 13, 2015 06:00
Show Gist options
  • Save sooop/8054359e7ecf5df25655 to your computer and use it in GitHub Desktop.
Save sooop/8054359e7ecf5df25655 to your computer and use it in GitHub Desktop.
@sh84ahn 님의 gist 에서 comprehension을 적용하도록 변경.
# [1,2,None]
# +[2,None,4]
# +[4,3,6]
# ------------
# [7, 5, 10]
a = [[1,2,None], [2,None,4], [4,3,6]]
def zipWith(f, d):
b =[[0 if x is None else x for x in y] for y in d]
return [f(x) for x in zip(*b)]
print(zipWith(sum, a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment