Commit dfc34e1a authored by Guido van Rossum's avatar Guido van Rossum

Replace the docs for reduce with an adaptation of its docstring, which

was actually clearer!
parent ea0ef224
...@@ -501,14 +501,15 @@ If the \module{readline} module was loaded, then ...@@ -501,14 +501,15 @@ If the \module{readline} module was loaded, then
line editing and history features. line editing and history features.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{reduce}{function, list\optional{, initializer}} \begin{funcdesc}{reduce}{function, sequence\optional{, initializer}}
Apply the binary \var{function} to the items of \var{list} so as to Apply \var{function} of two arguments cumulatively to the items of
reduce the list to a single value. E.g., \var{sequence}, from left to right, so as to reduce the sequence to
\code{reduce(lambda x, y: x*y, \var{list}, 1)} returns the product of a single value. For example,
the elements of \var{list}. The optional \var{initializer} can be \code{reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])} calculates
thought of as being prepended to \var{list} so as to allow reduction \code{((((1+2)+3)+4)+5)}.
of an empty \var{list}. The \var{list} arguments may be any kind of If the optional \var{initializer} is present, it is placed before the
sequence. items of the sequence in the calculation, and serves as a default when
the sequence is empty.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{reload}{module} \begin{funcdesc}{reload}{module}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment