函数式编程
高阶函数
1
2
3
4
5
|
In [ 4 ]: def func(x, y, f): ...: return f(x) + f(y) ...: In [ 5 ]: func( 3 , - 4 , abs ) Out[ 5 ]: 7 |
1
2
3
4
5
6
|
In [ 6 ]: import math In [ 7 ]: def add(x, y, f):...: return f(x) + f(y) ...: ...: In [ 8 ]: add( 9 , 25 , math.sqrt) Out[ 8 ]: 8.0 |
原文:https://www.cnblogs.com/heimaguangzhou/p/11769475.html