Function: -tree-mapreduce-from

-tree-mapreduce-from is a byte-compiled function defined in dash.el.

Signature

(-tree-mapreduce-from FN FOLDER INIT-VALUE TREE)

Documentation

Apply FN to each element of TREE, and make a list of the results.

If elements of TREE are lists themselves, apply FN recursively to elements of these nested lists.

Then reduce the resulting lists using FOLDER and initial value INIT-VALUE. See -reduce-r-from.

This is the same as calling -tree-reduce-from after -tree-map but is twice as fast as it only traverse the structure once.

View in manual

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -tree-mapreduce-from (fn folder init-value tree)
  "Apply FN to each element of TREE, and make a list of the results.
If elements of TREE are lists themselves, apply FN recursively to
elements of these nested lists.

Then reduce the resulting lists using FOLDER and initial value
INIT-VALUE. See `-reduce-r-from'.

This is the same as calling `-tree-reduce-from' after `-tree-map'
but is twice as fast as it only traverse the structure once."
  (declare (important-return-value t))
  (cond
   ((null tree) ())
   ((-cons-pair? tree) (funcall fn tree))
   ((consp tree)
    (-reduce-r-from
     folder init-value
     (mapcar (lambda (x) (-tree-mapreduce-from fn folder init-value x)) tree)))
   ((funcall fn tree))))