Skip to content

Commit da63022

Browse files
committed
函数式编程
1 parent d892920 commit da63022

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/函数式编程.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from functools import reduce
2+
3+
4+
def f(param):
5+
return param * param
6+
7+
8+
def add(x, y, z):
9+
return f(x) + z(y)
10+
11+
12+
print(add(1, 2, f))
13+
14+
15+
def fn(x, y):
16+
return x * 10 + y
17+
18+
19+
print(reduce(fn, [1, 2, 3, 4, 5]))

0 commit comments

Comments
 (0)