Typed Python?
Jakub Fast
kfast at poczta.onet.pl
Thu Jul 8 09:41:45 EDT 2004
Jacek Generowicz wrote:
> Ville Vainio <ville at spammers.com> writes:
>
>
>>>>>>>"Jakub" == Jakub Fast <kfast at poczta.onet.pl> writes:
>>
>> >> Currying: lambda x,y : f(x,y,1,2)
>> Jakub> lambda x: lambda y: f(x,y,1,2)?
>>
>> Jakub> but then
>> Jakub> (lambda x: lambda y: f(x,y,1,2))(3, 4)
>>
>> Jakub> won't work.
>>
>>Of course it won't. It's the difference b/w taking 1 and 2 parameters.
>
>
> Which is pretty much the point of currying.
>
>
>>(lambda x: lambda y: f(x,y,1,2))(3)(4)
>>
>>will work.
>>
>>I guess you will see that e.g in haskell
>>
>>f 1 2
>>
>>does exactly this:
>>
>>((f 1) 2 )
>>
>> Jakub> so much for currying?
>>
>>Well, no.
>
>
> Well, yes.
>
> In Haskell, both
>
> f 1
>
> and
>
> f 1 2
>
> will work, while in Python you have to install the plumbing yourself
> every time.
>
which is exactly what I meant.... :) With lambda x,y you can't just
curry the function. You can with lambda x: lambda y:, but then you can't
do regular application with it.
however, do take a look at
http://www.sourcekeg.co.uk/www.python.org/peps/pep-0309.html
which is getting in for 2.4 (?)
k
More information about the Python-list
mailing list