how lambda works with reduce

Viewed 1256

I was trying to understand how reduce works through this website. The example they have mentioned is quite good and easy to understand.

http://book.pythontips.com/en/latest/map_filter.html#reduce

a = reduce((lambda x, y: x * y), [1, 2, 3, 4])

The above function will multiple each and every number in list and assign to a.

However, I got totally stumped when I came across following function in project.

def compose(*fns):
    return reduce(lambda acc, fn: lambda *args: acc(fn(*args)), fns, lambda _: _)

could someone help me breakdown this function to understand what it's suppose to do

3 Answers
Related