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
dfc34e1a
Commit
dfc34e1a
authored
Jan 06, 1999
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the docs for reduce with an adaptation of its docstring, which
was actually clearer!
parent
ea0ef224
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
Doc/lib/libfuncs.tex
Doc/lib/libfuncs.tex
+9
-8
No files found.
Doc/lib/libfuncs.tex
View file @
dfc34e1a
...
...
@@ -501,14 +501,15 @@ If the \module{readline} module was loaded, then
line editing and history features.
\end{funcdesc}
\begin{funcdesc}
{
reduce
}{
function, list
\optional
{
, initializer
}}
Apply the binary
\var
{
function
}
to the items of
\var
{
list
}
so as to
reduce the list to a single value. E.g.,
\code
{
reduce(lambda x, y: x*y,
\var
{
list
}
, 1)
}
returns the product of
the elements of
\var
{
list
}
. The optional
\var
{
initializer
}
can be
thought of as being prepended to
\var
{
list
}
so as to allow reduction
of an empty
\var
{
list
}
. The
\var
{
list
}
arguments may be any kind of
sequence.
\begin{funcdesc}
{
reduce
}{
function, sequence
\optional
{
, initializer
}}
Apply
\var
{
function
}
of two arguments cumulatively to the items of
\var
{
sequence
}
, from left to right, so as to reduce the sequence to
a single value. For example,
\code
{
reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])
}
calculates
\code
{
((((1+2)+3)+4)+5)
}
.
If the optional
\var
{
initializer
}
is present, it is placed before the
items of the sequence in the calculation, and serves as a default when
the sequence is empty.
\end{funcdesc}
\begin{funcdesc}
{
reload
}{
module
}
...
...
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