Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automatic annotations for `for`
(defn- multi-perm
"Handles the case when you want the permutations of a list with duplicate items."
[l]
(let [f (frequencies l),
v (vec (distinct l)),
indices (apply concat
(for ^{::t/ann (t/Coll Long)} [^{::t/ann Long} i (range (count v))]
(repeat (f (v i)) i)))]
(map (partial map v) (lex-permutations indices))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.