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,17 @@
#lang racket
(require mzlib/list)
(define (merge xs ys) (merge-sorted-lists xs ys <=))
(define (strand-sort xs)
(let loop ([xs xs] [ys '[]])
(cond [(empty? xs) ys]
[else (define-values (sorted unsorted) (extract-strand xs))
(loop unsorted (merge sorted ys))])))
(define (extract-strand xs)
(for/fold ([strand '()] [unsorted '[]]) ([x xs])
(if (or (empty? strand) (< x (first strand)))
(values (cons x strand) unsorted)
(values strand (cons x unsorted)))))
(strand-sort (build-list 10 (λ(_) (random 15))))