Function: -rotate

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

Signature

(-rotate N LIST)

Documentation

Rotate LIST N places to the right (left if N is negative).

The time complexity is O(n).

View in manual

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -rotate (n list)
  "Rotate LIST N places to the right (left if N is negative).
The time complexity is O(n)."
  (declare (pure t) (side-effect-free t))
  (cond ((null list) ())
        ((zerop n) (copy-sequence list))
        ((let* ((len (length list))
                (n-mod-len (mod n len))
                (new-tail-len (- len n-mod-len)))
           (append (nthcdr new-tail-len list) (-take new-tail-len list))))))