forked from shaunwa/function-python-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_02.py
More file actions
executable file
·38 lines (27 loc) · 669 Bytes
/
04_02.py
File metadata and controls
executable file
·38 lines (27 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from functools import partial
def add(x, y, z):
return x + y + z
def add_partial(x):
def add_others(y, z):
return x + y + z
return add_others
add_5 = add_partial(5)
print(add_5(6, 7))
def add_partial_2(x, y):
def add_others(z):
return x + y + z
return add_others
add_5_and_6 = add_partial_2(5, 6)
print(add_5_and_6(7))
def curry_add(x):
def curry_add_inner(y):
def curry_add_inner_2(z):
return x + y + z
return curry_add_inner_2
return curry_add_inner
add_5 = curry_add(5)
add_5_and_6 = add_5(6)
print(add_5_and_6(7))
print(curry_add(5)(6)(7))
add_5 = partial(add, 5)
print(add_5(6, 7))