【发布时间】:2011-11-13 15:52:11
【问题描述】:
我正在尝试在 python 中编写一个函数,如下所示:
def repeated(f, n):
...
其中f 是一个接受一个参数的函数,n 是一个正整数。
例如,如果我将正方形定义为:
def square(x):
return x * x
我打电话给
repeated(square, 2)(3)
这将平方 3、2 次。
【问题讨论】:
标签: python higher-order-functions