[Python-checkins] python/dist/src/Doc/lib libitertools.tex, 1.31,
1.32
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Thu Sep 23 09:27:41 CEST 2004
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22472/Doc/lib
Modified Files:
libitertools.tex
Log Message:
Improve three recipes in the itertools docs.
Index: libitertools.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- libitertools.tex 11 Jul 2004 13:20:11 -0000 1.31
+++ libitertools.tex 23 Sep 2004 07:27:39 -0000 1.32
@@ -458,15 +458,21 @@
def all(seq, pred=bool):
"Returns True if pred(x) is True for every element in the iterable"
- return False not in imap(pred, seq)
+ for elem in ifilterfalse(pred, seq):
+ return False
+ return True
def any(seq, pred=bool):
- "Returns True if pred(x) is True at least one element in the iterable"
- return True in imap(pred, seq)
+ "Returns True if pred(x) is True for at least one element in the iterable"
+ for elem in ifilter(pred, seq):
+ return True
+ return False
def no(seq, pred=bool):
"Returns True if pred(x) is False for every element in the iterable"
- return True not in imap(pred, seq)
+ for elem in ifilter(pred, seq):
+ return False
+ return True
def quantify(seq, pred=bool):
"Count how many times the predicate is True in the sequence"
More information about the Python-checkins
mailing list