Function: -on

-on is a byte-compiled function defined in dash.el.

Signature

(-on OP TRANS)

Documentation

Return a function that calls TRANS on each arg and OP on the results.

The returned function takes a variable number of arguments, calls the function TRANS on each one in turn, and then passes those results as the list of arguments to OP, in the same order.

For example, the following pairs of expressions are morally equivalent:

  (funcall (-on #'+ #'1+) 1 2 3) = (+ (1+ 1) (1+ 2) (1+ 3))
  (funcall (-on #'+ #'1+)) = (+)

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -on (op trans)
  "Return a function that calls TRANS on each arg and OP on the results.
The returned function takes a variable number of arguments, calls
the function TRANS on each one in turn, and then passes those
results as the list of arguments to OP, in the same order.

For example, the following pairs of expressions are morally
equivalent:

  (funcall (-on #\\='+ #\\='1+) 1 2 3) = (+ (1+ 1) (1+ 2) (1+ 3))
  (funcall (-on #\\='+ #\\='1+))       = (+)"
  (declare (pure t) (side-effect-free error-free))
  (lambda (&rest args)
    ;; This unrolling seems to be a relatively cheap way to keep the
    ;; overhead of `mapcar' + `apply' in check.
    (cond ((cddr args)
           (apply op (mapcar trans args)))
          ((cdr args)
           (funcall op (funcall trans (car args)) (funcall trans (cadr args))))
          (args
           (funcall op (funcall trans (car args))))
          ((funcall op)))))