andmap and ormap
me at privacy.net
Tue Mar 14 13:31:20 CET 2006
On 14 Mar 2006 04:23:55 -0800,
wkehowski at cox.net wrote:
> Does python have andmap and ormap:
> andmap((lambda t: boolean(t)),L)
> gives True if boolean(t) is True for all t in L and False otherwise?
> ormap((lambda t: boolean(t)),L)
> gives True if boolean(t) is True for some t in L and False otherwise?
reduce( L, operator.and_ ) # andmap
reduce( L, operator.or_ ) # ormap
> One can use a list comprehension like
[ ... ]
> Is this good enough?
If it works, and works correctly, then it's good enough.
"I wish people would die in alphabetical order." -- My wife, the genealogist
More information about the Python-list