Created
December 12, 2011 19:27
-
-
Save jldupont/1468687 to your computer and use it in GitHub Desktop.
Partial Function application in python
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
def partial(fn, *pargs): | |
""" | |
Partial Function builder | |
>>> f=lambda p1,p2: p1+p2 | |
>>> pf=partial(f, 66) | |
>>> pf(44) | |
110 | |
""" | |
def _(*args): | |
plist=list(pargs) | |
plist.extend(list(args)) | |
return fn(*plist) | |
return _ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment