;;; Permute (shuffle): Return a random permutation of input vector. From Knuth ;;; "Algorithm P" (3rd ed, vol. 2, p. 145). ;;; vec: vector to permute ;;; Note that rint will have to be replaced with a different RNG proc. (define (permute vec) (do ((x (f64vector-quick-copy vec)) (j (fx- (f64vector-length vec) 1) (fx- j 1))) ((= j 0) x) (f64vector-swap! x j (rint 0 j))))