Function: -permutations

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

Signature

(-permutations LIST)

Documentation

Return the distinct permutations of LIST.

Duplicate elements of LIST are determined by equal, or by
-compare-fn if that is non-nil.

View in manual

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun -permutations (list)
  "Return the distinct permutations of LIST.

Duplicate elements of LIST are determined by `equal', or by
`-compare-fn' if that is non-nil."
  (declare (important-return-value t))
  (cond ((null list) (list ()))
        ;; Optimization: a traversal of `list' is faster than the
        ;; round trip via `dash--uniq-perms' or `dash--multi-perms'.
        ((dash--numbers<= list)
         (dash--lex-perms (vconcat list)))
        ((let ((freqs (-frequencies list)))
           ;; Is each element distinct?
           (unless (--every (= (cdr it) 1) freqs)
             (dash--multi-perms list freqs))))
        ((dash--uniq-perms list))))