Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 87e611e

Browse files
committed
Replace the docs for reduce with an adaptation of its docstring, which
was actually clearer!
1 parent 74429ea commit 87e611e

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,15 @@ \section{Built-in Functions \label{built-in-funcs}}
501501
line editing and history features.
502502
\end{funcdesc}
503503

504-
\begin{funcdesc}{reduce}{function, list\optional{, initializer}}
505-
Apply the binary \var{function} to the items of \var{list} so as to
506-
reduce the list to a single value. E.g.,
507-
\code{reduce(lambda x, y: x*y, \var{list}, 1)} returns the product of
508-
the elements of \var{list}. The optional \var{initializer} can be
509-
thought of as being prepended to \var{list} so as to allow reduction
510-
of an empty \var{list}. The \var{list} arguments may be any kind of
511-
sequence.
504+
\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}}
505+
Apply \var{function} of two arguments cumulatively to the items of
506+
\var{sequence}, from left to right, so as to reduce the sequence to
507+
a single value. For example,
508+
\code{reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])} calculates
509+
\code{((((1+2)+3)+4)+5)}.
510+
If the optional \var{initializer} is present, it is placed before the
511+
items of the sequence in the calculation, and serves as a default when
512+
the sequence is empty.
512513
\end{funcdesc}
513514

514515
\begin{funcdesc}{reload}{module}

0 commit comments

Comments
 (0)