[BangPypers] Currying in Python 3.0
Anand Balachandran Pillai
abpillai at gmail.com
Thu Dec 11 07:42:48 CET 2008
On Thu, Dec 11, 2008 at 12:09 PM, Anand Balachandran Pillai
<abpillai at gmail.com> wrote:
>
> So, if you have a function which accepts four arguments, say
>
>>>> curry(curry(f, 10), 20)
> <functools.partial object at 0x7f2d97bdf890>
>>>> curry(curry(curry(f, 10), 20), 30)
> <functools.partial object at 0x7f2d97bdf998>
>>>> curry(curry(curry(curry(f, 10), 20), 30), 40)
> <functools.partial object at 0x7f2d97bdfaa0>
>>>> def f(a,b,c,d): return a + b + c + d
>>>> curry(curry(curry(curry(f, 10), 20), 30), 40)()
> 100
Forgot to write the function. It is,
>>> def f(a,b,c,d): return a + b + c + d
--
-Anand
More information about the BangPypers
mailing list