Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,16 @@
#lang racket
(require (only-in srfi/43 vector-swap!))
(define (cocktail-sort! xs)
(define (ref i) (vector-ref xs i))
(define (swap i j) (vector-swap! xs i j))
(define len (vector-length xs))
(define (bubble from to delta)
(for/fold ([swaps 0]) ([i (in-range from to delta)])
(cond [(> (ref i) (ref (+ i 1)))
(swap i (+ i 1)) (+ swaps 1)]
[swaps])))
(let loop ()
(cond [(zero? (bubble 0 (- len 2) 1)) xs]
[(zero? (bubble (- len 2) 0 -1)) xs]
[(loop)])))