Gary King has posted his reaction to Leslie's shuffle algorithm. As always, his comments are very relevant.
I feel remiss for not posting a copy of Leslie's code here, so here it is:
I feel remiss for not posting a copy of Leslie's code here, so here it is:
(defun seqrnd (seq)
"Randomize the elements of a sequence. Destructive on SEQ."
(sort seq #'< :key (lambda (x) (random 1.0))))How elegant!
No comments:
Post a Comment