1
# Copyright 2005 by The University of Chicago
2
# Distributed under the LGPL license
3
# This work is partially supported by the US Department of Energy
4
# under award number DE-FG02-04ER25650
7
# Given f( x1 , x2 , x3 ), for example,
8
# g = curry( f , a , b ) is a function of one argument, x3,
9
# so that g( c ) has the same value as f( a , b , c )
10
# This class is useful in bypassing the scoping bugs for higher
11
# order functions in Python
13
def __init__( self , f , *first_args ):
15
self.first_args = first_args[:] # copy
16
def __call__( self , *xs ):
17
return self.f( *(self.first_args + xs) )