标签:
1 import operator 2 3 def average(*args): 4 return reduce(operator.add, args) / len(args) if args else 0
注释:
1 import functools 2 3 def average(*args): 4 acc = functools.partial(reduce, lambda x, y : x + y) 5 # acc = functools.partial(reduce, operator.add) 6 return acc(args) / len(args) if args else 0
注释:
Python函数式学习手记一: average in FP way
标签:
原文地址:http://www.cnblogs.com/ydlme/p/4293717.html