減少功能

Reduce 採用函式和項集合。它返回通過組合項建立的值。

這是一個簡單的減少。它返回集合中所有專案的總和。

total = reduce(lambda a, x: a + x, [0, 1, 2, 3, 4])
print(total)    =>10