2
;; Sleep sort implementation by Rodolfo Carvalho
7
(define (sleep-sort-simple lst)
8
(define M (apply max lst)) ; take maximum value and...
9
(for ([i (in-list lst)])
12
(sleep (/ i M)) ; ...sleep for at most 1 second
15
(define (sleep-sort lst)
16
(define M (apply max lst)) ; take maximum value and...
17
(define reverse-lst '())
19
(for/list ([i (in-list lst)])
22
(sleep (/ i M)) ; ...sleep for at most 1 second
23
(set! reverse-lst (cons i reverse-lst))))))
24
(reverse reverse-lst))
26
(sleep-sort-simple '(7 3 1 4 2))
29
(check-equal? (sleep-sort '(7 3 1 4 2)) '(1 2 3 4 7))
30
(check-equal? (sleep-sort (shuffle (build-list 100 values))) (build-list 100 values))
b'\\ No newline at end of file'