summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-01-06 23:10:51 (GMT)
committerGuido van Rossum <guido@python.org>1999-01-06 23:10:51 (GMT)
commit87e611e4416d6e56ea54b22cddb689bef2d4bebd (patch)
tree6402c01204bc146e821150e85b4b46e04390567e
parent74429eacb54dd388086d52fba21d68751ce3ee51 (diff)
downloadcpython-87e611e4416d6e56ea54b22cddb689bef2d4bebd.zip
cpython-87e611e4416d6e56ea54b22cddb689bef2d4bebd.tar.gz
cpython-87e611e4416d6e56ea54b22cddb689bef2d4bebd.tar.bz2
Replace the docs for reduce with an adaptation of its docstring, which
was actually clearer!
-rw-r--r--Doc/lib/libfuncs.tex17
1 files changed, 9 insertions, 8 deletions
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex
index d0b52a7..3f24101 100644
--- a/Doc/lib/libfuncs.tex
+++ b/Doc/lib/libfuncs.tex
@@ -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}