Hey Aria,

Here's my (not functional) but reasonably fast (Knuth) shuffle I've
been using.

(defn random-permutation [s]
  "Return a random permutation of this seq."
  (let [arr (to-array s) len (alength arr)]
    (dotimes [i (dec len)]
      (let [r (+ i (rand-int (- len i))),
            prev (aget arr i)]
        (aset arr i (aget arr r))
        (aset arr r prev)))
     (seq arr)))

-Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to