all in the range
> [0,n-1].
>
> A couple of style comments on your function perfect-functional-shuffle:
>
> I find it easier to read when a let or loop has multiple bindings on one
> line if it has commas between the symbol value pairs, e.g.:
>
> (loop [bst bst, rnd
r/src/ninety_nine_clojure/lists.clj#L273
Is generating a sequence of random values that are all in the range [0,n-1].
A couple of style comments on your function perfect-functional-shuffle:
I find it easier to read when a let or loop has multiple bindings on one
line if it has commas betwee
I tried to implement perfect functional shuffle in Clojure as outlined in
http://okmij.org/ftp/Haskell/perfect-shuffle.txt
This is purely for educational purposes as I am learning Clojure (so please
don't be too hard on me if I did something silly)
The code:
https://github.com/pebrc/n
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 (a
On Sun, Jan 4, 2009 at 10:17 PM, aria42 wrote:
>
> Hey all, I wanted to write a functional shuffle sequence (not lazy)
> rather than call out to Java.
See also:
http://groups.google.com/group/clojure/browse_thread/thread/180842eb58c58370
Hey all, I wanted to write a functional shuffle sequence (not lazy)
rather than call out to Java. If anyone is interested here it is. If
anyone thinks there is a better way to implement the rifle shuffle,
let me know. Not asserting it's the most efficient or anything.