diff options
author | Fred Drake <fdrake@acm.org> | 2002-07-17 13:55:33 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-07-17 13:55:33 (GMT) |
commit | 2095b9690fd2bab2e899b00c4a5c807671c178eb (patch) | |
tree | 2af835409a4d15a64f9d25034b364e3a7bf5ec33 /Doc/lib | |
parent | 1f4fed68e9dafe4a4a08aed9be8de56f5ae9ca6a (diff) | |
download | cpython-2095b9690fd2bab2e899b00c4a5c807671c178eb.zip cpython-2095b9690fd2bab2e899b00c4a5c807671c178eb.tar.gz cpython-2095b9690fd2bab2e899b00c4a5c807671c178eb.tar.bz2 |
reduce(): Clarified what is returned in the case of a sequence 1 item long and
initial/default value.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libfuncs.tex | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex index 5526dc5..1aa59dc 100644 --- a/Doc/lib/libfuncs.tex +++ b/Doc/lib/libfuncs.tex @@ -717,12 +717,12 @@ def my_import(name): \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. + 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. If \var{initializer} is not given and + \var{sequence} contains only one item, the first item is returned. \end{funcdesc} \begin{funcdesc}{reload}{module} |