How can I write code using FP

Leo Jay python.leojay at gmail.com
Wed Jan 17 04:34:00 CET 2007


On 16 Jan 2007 19:18:19 -0800, kernel1983 <kernel1983 at gmail.com> wrote:
>
> In Function Program,Language can use like this:
>
> define a function:
> f = lambda x,y:x,y
>
> then we use f to define another function:
> f2 = f(1)
> the f2 should equal to:
> f2=lambda y:1,y
>
> we should be able call f2 with one parameter:f2(2)
> just return 1,2
>
> but how can I implement the characteristic in Python??I think it could
> do like this but HOW-TO?
>
> thanks~~~
> I'm a English beginner!
> I wish somebody understand my meaning
>
>

try this:
foo = lambda x, y: (x, y)
foo1 = lambda x: foo(x,1)
foo2 = lambda y: foo(1,y)
print foo1(3)
print foo2(3)



-- 
Best Regards,
Leo Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070117/f12df318/attachment.html>


More information about the Python-list mailing list