Function: -reduce-r

-reduce-r is a byte-compiled function defined in dash.el.

Signature

(-reduce-r FN LIST)

Documentation

Reduce the function FN across LIST in reverse.

Return the result of applying FN to the last two elements of LIST, then applying FN to the third-to-last element and the previous result of FN, etc. That is, the first argument of FN is the current element, and its second argument the accumulated value. If LIST contains a single element, return it without calling FN. If LIST is empty, return the result of calling FN with no arguments.

This function is like -reduce but the operation associates from the right rather than left. In other words, it starts from the end of LIST and flips the arguments to FN. Conceptually, it is like replacing the conses in LIST with applications of FN, ignoring its last link, and evaluating the resulting expression.

This function's anaphoric counterpart is --reduce-r.

For other folds, see also -reduce-r-from and -reduce.

View in manual

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -reduce-r (fn list)
  "Reduce the function FN across LIST in reverse.
Return the result of applying FN to the last two elements of
LIST, then applying FN to the third-to-last element and the
previous result of FN, etc.  That is, the first argument of FN is
the current element, and its second argument the accumulated
value.  If LIST contains a single element, return it without
calling FN.  If LIST is empty, return the result of calling FN
with no arguments.

This function is like `-reduce' but the operation associates from
the right rather than left.  In other words, it starts from the
end of LIST and flips the arguments to FN.  Conceptually, it is
like replacing the conses in LIST with applications of FN,
ignoring its last link, and evaluating the resulting expression.

This function's anaphoric counterpart is `--reduce-r'.

For other folds, see also `-reduce-r-from' and `-reduce'."
  (declare (important-return-value t))
  (if list
      (--reduce-r (funcall fn it acc) list)
    (funcall fn)))