Skip to main content

Timeline for answer to Opposite of any() function by anon

Current License: CC BY-SA 3.0

Post Revisions

16 events
when toggle format what by license comment
Aug 19, 2016 at 20:44 audit First posts
Aug 19, 2016 at 20:44
Aug 18, 2016 at 16:54 audit First posts
Aug 18, 2016 at 17:55
Aug 17, 2016 at 15:38 comment added anon @ShaneHsu: What do you mean by "doesn't short circuit"? The all call terminates on the first False found and is thus much faster for a call with False at the start and slower for all True - I would describe that as short circuiting.
Aug 16, 2016 at 21:55 comment added dawg @ShaneHsu: Short circuiting may not be faster than native C code of all
Aug 16, 2016 at 18:54 comment added Shane Hsu This doesn't short circuit though, if that is the desired behavior.
Aug 11, 2016 at 16:42 comment added Arturo Torres Sánchez @Lafexlos, yes, all returns True on an empty set because that's how the underlying math works.
Aug 11, 2016 at 4:18 vote accept Ekeyme Mo
Aug 10, 2016 at 16:22 comment added BlueRaja - Danny Pflughoeft +1 A little knowledge of mathematical logic can save a lot of time in the long run: ∃x: ¬x is equivalent to ¬(∀x: x). See here
Aug 10, 2016 at 13:31 comment added anon @Fermiparadox: Doing some quick timings this is much faster than the any approach as you'd expect since it's all built-in. Deceze's approach is more generally applicable, however.
Aug 10, 2016 at 13:30 history rollback anon
Rollback to Revision 1
Aug 10, 2016 at 13:29 history edited Petko.Maria.John CC BY-SA 3.0
added 7 characters in body
Aug 10, 2016 at 12:14 comment added VPfB For all(...) you can always add True to the argument list without changing the output. True is a "neutral element" (just like 0 for addition, 1 for multiplication are neutral elements). That's why empty all() returns True. For any() the neutral element is False.
Aug 10, 2016 at 11:07 comment added anon @Lafexlos Good point, it's always worth considering the end points. I would guess that False for [] is the correct answer; which this code give but the OP would have to specify.
Aug 10, 2016 at 9:48 review Suggested edits
Aug 10, 2016 at 10:24
Aug 10, 2016 at 9:30 comment added Lafexlos Not sure what OP wants if iterable is empty but it's worth noting, all returns True on empty iterable.
Aug 10, 2016 at 9:23 history answered anon CC BY-SA 3.0