Archives for: September 2006, 27

09/27/06

Permalink 09:20:41 pm, Categories: Python, 43 words   English (US)

Finding truth

Let's say you have a list:

foo = [True, False, False, True]

and you want to do a simple AND across all elements. Here's a quick way:

result = reduce(lambda x, y: x and y, foo)

result would be False in the above example.

Viraj's Weblog

Donate to keep this site going!

Amount USD $

September 2006
Mon Tue Wed Thu Fri Sat Sun
<<  <   >  >>
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  

Search

Categories


Misc

Syndicate this blog XML

What is RSS?

powered by
b2evolution