Reduce Abstraction

Reduce

Syntax

Reduce takes a list, a binary operation, and an identity element for the operation. It returns a value representing the binary operator applied to successive application of the operations to intermediate results.

Example

from functools import reduce
product = reduce((lambda x, y: x * y), [47, 11, 42, 13])

# Output: 113

Last updated