Fredrik Lundh wrote: > 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>
Thanks Frederik. I actually have a set of lambdas so my use will be more like: >>> s = set([lambda : A < B, lambda : C+6 >= 7]) >>> x=s.pop(); y=s.pop() >>> Z=lambda x=x, y=y: x() and y() >>> del x,y >>> A,B,C = [2,3,1] >>> Z() True >>> A,B,C = [2,3,0] >>> Z() False >>> A,B,C = [3,3,1] >>> Z() False >>> - Gosh, isn't life fun! - Pad. -- http://mail.python.org/mailman/listinfo/python-list