Powered by Jupyter Book
import functools
mysum = functools.partial(functools.reduce, lambda x, y: x+y) mysum([1,2,3,2,1])
9
mymax = functools.partial(functools.reduce, lambda x, y: x if x>=y else y) mymax([1,2,3,2,1])
3
myaverage = lambda list_ : mysum(list_) / len(list_) myaverage([1,2,3])
2.0