master
Avril 5 years ago
parent af3c747de5
commit 33383583ac
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -26,3 +26,15 @@
(export 'weighted) (export 'weighted)
(defun shuffle! (sequence &key (provider *default-randomness-provider*))
(if (listp sequence)
(loop for i from (1- (length sequence)) above 0 do
(rotatef (nth i sequence)
(nth (funcall provider :limit i :transform #'floor) sequence)))
(loop for i from (1- (length sequence)) above 0 do
(rotatef (aref sequence i)
(aref sequence (funcall provider :limit i :transform #'floor)))))
sequence)
(export 'shuffle!)

Loading…
Cancel
Save