From: Lars Ingebrigtsen Date: Thu, 15 Oct 2020 07:37:44 +0000 (+0200) Subject: Clarify the seq-reduce documentation X-Git-Tag: emacs-27.1.90~103^2~8 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ace25f206640b94d876d7d0966fcd9e512f81fc9;p=emacs.git 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). --- diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index ca52369bd0c..952834bd4e3 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi @@ -658,8 +658,13 @@ for which @var{predicate} returns @code{nil}. @var{initial-value} and the first element of @var{sequence}, then calling @var{function} with that result and the second element of @var{sequence}, then with that result and the third element of @var{sequence}, etc. -@var{function} should be a function of two arguments. If -@var{sequence} is empty, this returns @var{initial-value} without +@var{function} should be a function of two arguments. + +@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}. @example diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index e3037a71901..42b145da2fd 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -336,9 +336,11 @@ list." "Reduce the function FUNCTION across SEQUENCE, starting with INITIAL-VALUE. Return the result of calling FUNCTION with INITIAL-VALUE and the -first element of SEQUENCE, then calling FUNCTION with that result and -the second element of SEQUENCE, then with that result and the third -element of SEQUENCE, etc. +first element of SEQUENCE, then calling FUNCTION with that result +and the second element of SEQUENCE, then with that result and the +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 (seq-empty-p sequence)