Skip to content

Instantly share code, notes, and snippets.

@chuck0523

chuck0523/reduce.py

Last active May 20, 2016
Embed
What would you like to do?
# 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