Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -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)