add contract check to shuffle

This commit is contained in:
Robby Findler 2017-11-07 12:29:57 -06:00
parent 3cb7044976
commit afde639ec5

View File

@ -601,6 +601,7 @@
;; Fisher-Yates Shuffle
(define (shuffle l)
(unless (list? l) (raise-argument-error 'shuffle "list?" 0 l))
(define a (make-vector (length l)))
(for ([x (in-list l)] [i (in-naturals)])
(define j (random (add1 i)))