面试题答案
一键面试# 定义操作函数
operation_one = lambda x: x + 1
operation_two = lambda x: x * 2
operation_three = lambda x: x ** 2
# 高阶函数构建管道
def compose(*functions):
def inner(x):
for func in functions:
x = func(x)
return x
return inner
# 构建具体管道并应用于数字5
pipeline = compose(operation_one, operation_three, operation_two)
result = pipeline(5)
print(result)