Skip to content

Instantly share code, notes, and snippets.

@amalloy
Forked from kpmaynard/gist:8367053
Last active January 2, 2016 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/8367369 to your computer and use it in GitHub Desktop.
Save amalloy/8367369 to your computer and use it in GitHub Desktop.
(defn permx [coll]
(letfn [(helper [m]
(if (empty? m)
'(())
(for [[i x] m
perm (helper (dissoc m i))]
(cons x perm))))]
(helper (into (sorted-map)
(map-indexed vector coll)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment