-
-
Save tomjack/9fd979fdaef47ea67da0 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> (let [r (java.util.Random.)] [(permute {0 1 2 3} r) (permute {2 3 0 1} r)]) | |
[{1 3, 0 1} {0 1, 1 3}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment