-
-
Save tomjack/35f2c6854ad0e721cf89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn shuffle-rand [coll rand] | |
(let [al (java.util.ArrayList. coll)] | |
(java.util.Collections/shuffle al rand) | |
(clojure.lang.RT/vector (.toArray al)))) | |
(defn permute [v rand] | |
(zipmap (shuffle-rand (range (count v)) rand) (vals v))) | |
scratch.vectors> (map permute [{0 1 2 3} {2 3 0 1}] (repeatedly #(java.util.Random. 57357357357))) | |
({1 3, 0 1} {1 1, 0 3}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment