Last active
December 7, 2017 10:48
-
-
Save yuliji/0b929160aaabbd5215ee81aa904a1c8d to your computer and use it in GitHub Desktop.
[python partial function, currying]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# currying | |
def make_in_list(alist): | |
def in_list(e): | |
return e in alist | |
return in_list | |
in_list = make_in_list([1,2,3,4,5]) | |
in_list(9) | |
# partial | |
import functools | |
def e_in_list(e, alist): | |
return e in alist | |
e_in_123 = functools.partial(e_in_list, alist=[1,2,3]) | |
e_in_123(1) | |
e_in_123(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment