mirror of https://github.com/python/cpython
reduce(): Clarified what is returned in the case of a sequence 1 item long and
initial/default value.
This commit is contained in:
parent
1f4fed68e9
commit
2095b9690f
|
@ -717,12 +717,12 @@ def my_import(name):
|
|||
\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.
|
||||
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. If \var{initializer} is not given and
|
||||
\var{sequence} contains only one item, the first item is returned.
|
||||
\end{funcdesc}
|
||||
|
||||
\begin{funcdesc}{reload}{module}
|
||||
|
|
Loading…
Reference in New Issue