Skip to content

Instantly share code, notes, and snippets.

@jldupont
Created December 12, 2011 19:27
Show Gist options
  • Save jldupont/1468687 to your computer and use it in GitHub Desktop.
Save jldupont/1468687 to your computer and use it in GitHub Desktop.
Partial Function application in python
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