Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
84fc7081
Commit
84fc7081
authored
Oct 12, 2013
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
9809ca9d
64801680
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
Doc/library/functools.rst
Doc/library/functools.rst
+12
-0
Doc/library/itertools.rst
Doc/library/itertools.rst
+3
-0
No files found.
Doc/library/functools.rst
View file @
84fc7081
...
...
@@ -205,6 +205,18 @@ The :mod:`functools` module defines the following functions:
a default when the sequence is empty. If *initializer* is not given and
*sequence* contains only one item, the first item is returned.
Equivalent to::
def reduce(function, iterable, initializer=None):
it = iter(iterable)
if initializer is None:
value = next(it)
else:
value = initializer
for element in it:
value = function(value, element)
return value
.. decorator:: singledispatch(default)
...
...
Doc/library/itertools.rst
View file @
84fc7081
...
...
@@ -135,6 +135,9 @@ loops that truncate the stream.
'0.93', '0.25', '0.71', '0.79', '0.63', '0.88', '0.39', '0.91', '0.32',
'0.83', '0.54', '0.95', '0.20', '0.60', '0.91', '0.30', '0.80', '0.60']
See :func:`functools.reduce` for a similar function that returns only the
final accumulated value.
.. versionadded:: 3.2
.. versionchanged:: 3.3
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment