Clarify the seq-reduce documentation

* doc/lispref/sequences.texi (Sequence Functions): Ditto.

* lisp/emacs-lisp/seq.el (seq-reduce): Clarify the order of the
arguments (bug#43995).
This commit is contained in:
Lars Ingebrigtsen 2020-10-15 09:37:44 +02:00
parent 7d598e281d
commit ace25f2066
2 changed files with 12 additions and 5 deletions

View file

@ -658,8 +658,13 @@ for which @var{predicate} returns @code{nil}.
@var{initial-value} and the first element of @var{sequence}, then calling @var{initial-value} and the first element of @var{sequence}, then calling
@var{function} with that result and the second element of @var{sequence}, @var{function} with that result and the second element of @var{sequence},
then with that result and the third element of @var{sequence}, etc. then with that result and the third element of @var{sequence}, etc.
@var{function} should be a function of two arguments. If @var{function} should be a function of two arguments.
@var{sequence} is empty, this returns @var{initial-value} without
@var{function} is called with two arguments. @var{intial-value}
(and then the accumulated value) is used as the first argument, and
the elements in @var{sequence} are used for the second argument.
If @var{sequence} is empty, this returns @var{initial-value} without
calling @var{function}. calling @var{function}.
@example @example

View file

@ -336,9 +336,11 @@ list."
"Reduce the function FUNCTION across SEQUENCE, starting with INITIAL-VALUE. "Reduce the function FUNCTION across SEQUENCE, starting with INITIAL-VALUE.
Return the result of calling FUNCTION with INITIAL-VALUE and the Return the result of calling FUNCTION with INITIAL-VALUE and the
first element of SEQUENCE, then calling FUNCTION with that result and first element of SEQUENCE, then calling FUNCTION with that result
the second element of SEQUENCE, then with that result and the third and the second element of SEQUENCE, then with that result and the
element of SEQUENCE, etc. third element of SEQUENCE, etc. FUNCTION will be called with
INITIAL-VALUE (and then the accumulated value) as the first
argument, and the elements from SEQUENCE as the second argument.
If SEQUENCE is empty, return INITIAL-VALUE and FUNCTION is not called." If SEQUENCE is empty, return INITIAL-VALUE and FUNCTION is not called."
(if (seq-empty-p sequence) (if (seq-empty-p sequence)