Last active
May 20, 2016 17:18
-
-
Save chuck0523/6e7a46cff9654e7c9cef5b2d085b1e8d to your computer and use it in GitHub Desktop.
This file contains 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
# coding: UTF-8 | |
# Python3では、reduce関数はコア関数ではない。ので、importが必要。 | |
from functools import reduce | |
def add(x, y): | |
return x + y | |
print(reduce(add, range(1, 5))) # 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment