def linear(a, b):
def result(x):
return a * x + b
return result
--来源https://docs.python.org/3.5/faq/programming.html#how-do-you-make-a-higher-order-function-in-python
>>> a = linear(5,5) #linear(5,5)
>>> a(0) #result(0) --> linear(5,5)
5
>>> a(1)
10
>>> a(2)
15
>>> a = linear(5,10)
>>> a(0)
10
>>> a(1)
15