Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,13 +1,9 @@
|
|||
(require racket/match)
|
||||
#lang racket
|
||||
|
||||
(define (sort pred l)
|
||||
(define (sort < l)
|
||||
(define (insert x y)
|
||||
(match (list x y)
|
||||
[(list x '()) (list x)]
|
||||
[(list x (cons y ys))
|
||||
(if (pred x y)
|
||||
(cons x (cons y ys))
|
||||
(cons y (f x ys)))]))
|
||||
(match l
|
||||
['() '()]
|
||||
[(cons x xs) (insert x (sort pred xs))]))
|
||||
(match* (x y)
|
||||
[(x '()) (list x)]
|
||||
[(x (cons y ys)) (cond [(< x y) (list* x y ys)]
|
||||
[else (cons y (insert x ys))])]))
|
||||
(foldl insert '() l))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue