📜  funtools 大致相当于内部 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:21.391000             🧑  作者: Mango

代码示例1
def reduce(function, iterable, initializer=None):
    it = iter(iterable)
    if initializer is None:
        value = next(it)
    else:
        value = initializer
    for element in it:
        value = function(value, element)
    return value