Skip to content

Instantly share code, notes, and snippets.

@yuliji
Last active December 7, 2017 10:48
Show Gist options
  • Save yuliji/0b929160aaabbd5215ee81aa904a1c8d to your computer and use it in GitHub Desktop.
Save yuliji/0b929160aaabbd5215ee81aa904a1c8d to your computer and use it in GitHub Desktop.
[python partial function, currying]
# 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