def reduce ( function , initval = None ) : if initval is None : return lambda s : __builtin__ . reduce ( function , s ) else : return lambda s : __builtin__ . reduce ( function , s , initval )
how to make a function return a fuction in python
Curried version of the built - in reduce . >>> reduce ( lambda x y : x + y ) ( [ 1 2 3 4 5 ] ) 15
def reduce(function, initval=None):
	"""
	Curried version of the built-in reduce.
	
	>>> reduce(lambda x,y: x+y)( [1, 2, 3, 4, 5] )
	15
	"""
	if initval is None:
		return lambda s: __builtin__.reduce(function, s)
	else:
		return lambda s: __builtin__.reduce(function, s, initval)