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):
destination = origin
for func in function_list:
destination = func(destination)
return destination
With each function in function_list having a single argument.
I'd like to know if there is a similar function in python standard library or a better way (example: using lambdas) to do this.
foldr ($) 7 [(+1), (^3), (*2)]evaluates to2745.($)is simply\f x -> f x. Soreduceandlambdawould be the python equivalent.foldr ($) x [(+1),(^2)]vsfoldr (.) id [(+1),(^2)] $ x.