python 3.0以后, reduce已经不在built-in function里了, 要用它就得from functools import reduce. reduce的用法 reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence,from left to right, so as to reduce the…
http://yi-programmer.com/2011-02-24_fold.html http://c2.com/cgi/wiki?FoldFunction http://rwh.readthedocs.org/en/latest/chp/4.html The PythonLanguage calls it reduce; this is a left fold: reduce(operator.add, [1,2,3,4]) reduce(lambda x,y: x+y, [1,2,3,…