diff options
author | Raymond Hettinger <python@rcn.com> | 2016-03-07 02:12:08 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-03-07 02:12:08 (GMT) |
commit | 20b3e72b8df89aedcbaa17c4920da2f670ee1d84 (patch) | |
tree | 7ce74b04d7487946984342be4f37f15f521fd8cd /Doc | |
parent | a2998a63c8951ab8254b96860fe64dcaa215eb1f (diff) | |
parent | e525ee3b483889313b62b09b4c9103d18dd9cbb7 (diff) | |
download | cpython-20b3e72b8df89aedcbaa17c4920da2f670ee1d84.zip cpython-20b3e72b8df89aedcbaa17c4920da2f670ee1d84.tar.gz cpython-20b3e72b8df89aedcbaa17c4920da2f670ee1d84.tar.bz2 |
Merge
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/itertools.rst | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 9dac5e1..a9d1073 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -693,6 +693,11 @@ which incur interpreter overhead. "Returns the nth item or a default value" return next(islice(iterable, n, None), default) + def all_equal(iterable): + "Returns True if all the elements are equal to each other" + g = groupby(iterable) + return next(g, True) and not next(g, False) + def quantify(iterable, pred=bool): "Count how many times the predicate is true" return sum(map(pred, iterable)) |