[ create a new paste ] login | about

Link: http://codepad.org/mxUZ0Zdu    [ raw code | output | fork ]

scwizard - Python, pasted on Dec 17:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def curry(func, *args, **keywords):
	def recur(*missing_args, **missing_keywords):
		if (not missing_args) and (not missing_keywords):
			return func(*args, **keywords)
		else:
			new_keywords = keywords.copy()
			new_keywords.update(missing_keywords)
			return curry(func, *(args + missing_args), **new_keywords)			
	return recur

def sumfive(a, b, c, d, e):
	return a + b + c + d + e

print curry(sumfive)(1)(2)(3)(4)(5)()


Output:
1
15


Create a new paste based on this one


Comments: