diff options
author | Raymond Hettinger <python@rcn.com> | 2003-10-05 16:47:36 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-10-05 16:47:36 (GMT) |
commit | dbe3d280e70c8a2a5542839a118333d645192b79 (patch) | |
tree | 220b97aec9f8b56de7fd4ffa1013514efb6094fc /Lib/test/test_itertools.py | |
parent | 2f726e9093381572b21edbfc42659ea89fbdf686 (diff) | |
download | cpython-dbe3d280e70c8a2a5542839a118333d645192b79.zip cpython-dbe3d280e70c8a2a5542839a118333d645192b79.tar.gz cpython-dbe3d280e70c8a2a5542839a118333d645192b79.tar.bz2 |
Adopt Christian Stork's suggested argument order for the logic quantifiers.
Adopt Jeremy Fincher's suggested function name, "any", instead of "some".
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r-- | Lib/test/test_itertools.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 7842dd3..0880be3 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -504,19 +504,19 @@ Samuele ... "Returns the nth item" ... return list(islice(iterable, n, n+1)) ->>> def all(pred, seq): +>>> 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 some(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(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(pred, seq): +>>> def quantify(seq, pred=bool): ... "Count how many times the predicate is True in the sequence" ... return sum(imap(pred, seq)) @@ -571,25 +571,25 @@ perform as purported. >>> nth('abcde', 3) ['d'] ->>> all(lambda x: x%2==0, [2, 4, 6, 8]) +>>> all([2, 4, 6, 8], lambda x: x%2==0) True ->>> all(lambda x: x%2==0, [2, 3, 6, 8]) +>>> all([2, 3, 6, 8], lambda x: x%2==0) False ->>> some(lambda x: x%2==0, [2, 4, 6, 8]) +>>> any([2, 4, 6, 8], lambda x: x%2==0) True ->>> some(lambda x: x%2==0, [1, 3, 5, 9]) +>>> any([1, 3, 5, 9], lambda x: x%2==0,) False ->>> no(lambda x: x%2==0, [1, 3, 5, 9]) +>>> no([1, 3, 5, 9], lambda x: x%2==0) True ->>> no(lambda x: x%2==0, [1, 2, 5, 9]) +>>> no([1, 2, 5, 9], lambda x: x%2==0) False ->>> quantify(lambda x: x%2==0, xrange(99)) +>>> quantify(xrange(99), lambda x: x%2==0) 50 >>> list(window('abc')) |