Function: -rotate-args

-rotate-args is a byte-compiled function defined in dash.el.

Signature

(-rotate-args N FN)

Documentation

Return a function that calls FN with args rotated N places to the right.

The returned function takes the same number of arguments as FN, rotates the list of arguments N places to the right (left if N is negative) just like -rotate, and applies FN to the result.

See also: -flip.

View in manual

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -rotate-args (n fn)
  "Return a function that calls FN with args rotated N places to the right.
The returned function takes the same number of arguments as FN,
rotates the list of arguments N places to the right (left if N is
negative) just like `-rotate', and applies FN to the result.

See also: `-flip'."
  (declare (pure t) (side-effect-free t))
  (if (zerop n)
      fn
    (let ((even (= (% n 2) 0)))
      (lambda (&rest args)
        (cond ((cddr args) ;; Open-code for speed.
               (apply fn (-rotate n args)))
              ((cdr args)
               (let ((fst (car args))
                     (snd (cadr args)))
                 (funcall fn (if even fst snd) (if even snd fst))))
              (args
               (funcall fn (car args)))
              ((funcall fn)))))))