Is this the best way to test every item in a list?

def alltrue(f,l):
    return reduce(bool.__and__,map(f,l))

def onetrue(f,l):
    return reduce(bool.__or__,map(f,l))

>>> alltrue(lambda x:x>1,[1,2,3])
False
>>>
>>> alltrue(lambda x:x>=1,[1,2,3])
True
>>>

Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to