Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,14 +1,14 @@
|
|||
#lang racket
|
||||
(define (shell-sort! xs)
|
||||
(define (ref i) (vector-ref xs i))
|
||||
(define (new Δ) (if (= Δ 2) 1 (exact-floor (/ (* Δ 5) 11))))
|
||||
(define ref (curry vector-ref xs))
|
||||
(define (new Δ) (if (= Δ 2) 1 (quotient (* Δ 5) 11)))
|
||||
(let loop ([Δ (quotient (vector-length xs) 2)])
|
||||
(unless (= Δ 0)
|
||||
(for ([xi (in-vector xs)] [i (in-naturals)])
|
||||
(for ([xᵢ (in-vector xs)] [i (in-naturals)])
|
||||
(let while ([i i])
|
||||
(cond [(and (>= i Δ) (> (ref (- i Δ)) xi))
|
||||
(cond [(and (>= i Δ) (> (ref (- i Δ)) xᵢ))
|
||||
(vector-set! xs i (ref (- i Δ)))
|
||||
(while (- i Δ))]
|
||||
[(vector-set! xs i xi)])))
|
||||
[else (vector-set! xs i xᵢ)])))
|
||||
(loop (new Δ))))
|
||||
xs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue