Function: dash--multi-perms

dash--multi-perms is a byte-compiled function defined in dash.el.

Signature

(dash--multi-perms LIST FREQS)

Documentation

Return a list of permutations of the multiset LIST.

FREQS should be an alist describing the frequency of each element in LIST, as returned by -frequencies.

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun dash--multi-perms (list freqs)
  "Return a list of permutations of the multiset LIST.
FREQS should be an alist describing the frequency of each element
in LIST, as returned by `-frequencies'."
  (let (;; Distinct items in `list', aka the cars of `freqs'.
        (uniq (make-vector (length freqs) nil))
        ;; Indices into `uniq'.
        (idxs (make-vector (length list) nil))
        ;; Current index into `idxs'.
        (i 0))
    (--each freqs
      (aset uniq it-index (car it))
      ;; Populate `idxs' with as many copies of each `it-index' as
      ;; there are corresponding duplicates.
      (dotimes (_ (cdr it))
        (aset idxs i it-index)
        (setq i (1+ i))))
    (dash--lex-perms idxs uniq)))