mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Part of SF patch #1513870 (the still relevant part) -- add reduce() to
functools, and adjust docs etc.
This commit is contained in:
parent
6a2a2a0832
commit
0919a1a07b
11 changed files with 168 additions and 78 deletions
|
@ -51,6 +51,19 @@ two:
|
|||
\end{verbatim}
|
||||
\end{funcdesc}
|
||||
|
||||
\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)}. The left argument,
|
||||
\var{x}, is the accumulated value and the right argument, \var{y},
|
||||
is the update value from the \var{sequence}. 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}{update_wrapper}
|
||||
{wrapper, wrapped\optional{, assigned}\optional{, updated}}
|
||||
Update a wrapper function to look like the wrapped function. The optional
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue