Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -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))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue