diff options
Diffstat (limited to 'Doc/lib/libfunctools.tex')
-rw-r--r-- | Doc/lib/libfunctools.tex | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Doc/lib/libfunctools.tex b/Doc/lib/libfunctools.tex index 33a6f52..034143a 100644 --- a/Doc/lib/libfunctools.tex +++ b/Doc/lib/libfunctools.tex @@ -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 |