Compute a chain of functions in python

后端 未结 1 1418
一整个雨季
一整个雨季 2021-02-13 11:24

I want to get the result of a chain of computations from an initial value. I\'m actually using the following code:

def function_composition(function_list, origin         


        
1条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-13 12:05

    Fold while calling.

    destination = reduce((lambda x, y: y(x)), function_list, origin)
    

    0 讨论(0)
提交回复
热议问题