1.3.0 permalink Arrow_down_16x16

shuffle

clojure.core

  • (shuffle coll)
Return a random permutation of coll

1 Example top

  • user=> (repeatedly 5 (partial shuffle [1 2 3]))
    ([1 2 3] [1 2 3] [1 2 3] [1 2 3] [3 1 2])
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:6303 top

(defn shuffle
  "Return a random permutation of coll"
  {:added "1.2"
   :static true}
  [^java.util.Collection coll]
  (let [al (java.util.ArrayList. coll)]
    (java.util.Collections/shuffle al)
    (clojure.lang.RT/vector (.toArray al))))
Vars in clojure.core/shuffle:
Used in 0 other vars

Comments top

No comments for shuffle. Log in to add a comment.