First page Back Continue Last page Overview Graphics

reduce-Function

The function reduce has been “banned” to the functools module!

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 sequence to a single value.

If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.

[s1, s2, s3, s4]

func(s1,s2)

func(func(s1,s2),s3)

func(func(func(s1,s2),s3),s4)