by kmcgivney · 17y ago · 0 comments
(defun shuffle-in-place (l)
(cond ((null l) nil)
(t (rotatef (nth 0 l)
(nth (random (length l)) l))
(shuffle-in-place (rest l))))
l)
(defun shuffle (l)
(shuffle-in-place (copy-list l)))I do. Always.
One could use nconc instead of append, but that's not where the processor cycles are being lost as far as I can tell.