fold

What is the 'pythonic' equivalent to the 'fold' function from functional programming?

What is the 'pythonic' equivalent to the 'fold' function from functional programming? Question: What is the most idiomatic way to achieve something like the following, in Haskell: foldl (+) 0 [1,2,3,4,5] –> 15 Or its equivalent in Ruby: [1,2,3,4,5].inject(0) {|m,x| m + x} #> 15 Obviously, Python provides the reduce function, which is an implementation …

Total answers: 8