[Python-checkins] python/dist/src/Lib/test test_itertools.py, 1.15.6.3, 1.15.6.4

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun Oct 5 19:05:58 EDT 2003


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv13802/Lib/test

Modified Files:
      Tag: release23-maint
	test_itertools.py 
Log Message:
Adopt Christian Stork's suggested argument order for quantifier examples.

Adopt Jeremy Fincher's suggested function name, "any", instead of "some".



Index: test_itertools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v
retrieving revision 1.15.6.3
retrieving revision 1.15.6.4
diff -C2 -d -r1.15.6.3 -r1.15.6.4
*** test_itertools.py	2 Sep 2003 04:19:02 -0000	1.15.6.3
--- test_itertools.py	5 Oct 2003 23:05:55 -0000	1.15.6.4
***************
*** 502,518 ****
  ...     return list(islice(iterable, n, n+1))
  
! >>> def all(pred, seq):
  ...     "Returns True if pred(x) is True for every element in the iterable"
  ...     return False not in imap(pred, seq)
  
! >>> def some(pred, seq):
  ...     "Returns True if pred(x) is True for at least one element in the iterable"
  ...     return True in imap(pred, seq)
  
! >>> def no(pred, seq):
  ...     "Returns True if pred(x) is False for every element in the iterable"
  ...     return True not in imap(pred, seq)
  
! >>> def quantify(pred, seq):
  ...     "Count how many times the predicate is True in the sequence"
  ...     return sum(imap(pred, seq))
--- 502,518 ----
  ...     return list(islice(iterable, n, n+1))
  
! >>> 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)
  
! >>> def any(seq, pred=bool):
  ...     "Returns True if pred(x) is True for at least one element in the iterable"
  ...     return True in imap(pred, seq)
  
! >>> 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)
  
! >>> def quantify(seq, pred=bool):
  ...     "Count how many times the predicate is True in the sequence"
  ...     return sum(imap(pred, seq))
***************
*** 555,577 ****
  ['d']
  
! >>> all(lambda x: x%2==0, [2, 4, 6, 8])
  True
  
! >>> all(lambda x: x%2==0, [2, 3, 6, 8])
  False
  
! >>> some(lambda x: x%2==0, [2, 4, 6, 8])
  True
  
! >>> some(lambda x: x%2==0, [1, 3, 5, 9])
  False
  
! >>> no(lambda x: x%2==0, [1, 3, 5, 9])
  True
  
! >>> no(lambda x: x%2==0, [1, 2, 5, 9])
  False
  
! >>> quantify(lambda x: x%2==0, xrange(99))
  50
  
--- 555,577 ----
  ['d']
  
! >>> all([2, 4, 6, 8], lambda x: x%2==0)
  True
  
! >>> all([2, 3, 6, 8], lambda x: x%2==0)
  False
  
! >>> any([2, 4, 6, 8], lambda x: x%2==0)
  True
  
! >>> any([1, 3, 5, 9], lambda x: x%2==0,)
  False
  
! >>> no([1, 3, 5, 9], lambda x: x%2==0)
  True
  
! >>> no([1, 2, 5, 9], lambda x: x%2==0)
  False
  
! >>> quantify(xrange(99), lambda x: x%2==0)
  50
  





More information about the Python-checkins mailing list