combining several lambda equations

Fredrik Lundh fredrik at pythonware.com
Fri Feb 18 05:33:32 EST 2005


Paddy McCarthy wrote:

> #If given:two or more lambda equations
> x=lambda : A < B
> y=lambda : C+6 >= 7
>
> How do I create another lambda expression Z equivalent to
>
> Z=lambda : (A<B) and (C+6>=7)
>
> # i.e. the anding together of the originals, but without referencing
> # globals x and y as they are artificial in that I will start of with
> # probably a list of lambda equations.

    x=lambda : A < B
    y=lambda : C+6 >= 7
    Z=lambda x=x, y=y: x() and y()
    del x, y

</F> 






More information about the Python-list mailing list