home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0963.lha
/
SIOD
/
scm
/
mer-sor.scm
< prev
next >
Wrap
Text File
|
1993-09-25
|
581b
|
17 lines
(define (merge-list x y)
(cond ((null? x) y)
((null? y) x)
(else (if (test (car x) (car y))
(cons (car x) (merge-list (cdr x) y))
(cons (car y) (merge-list x (cdr y)))))))
(define (merge-sort x)
(if (null? x)
nil
(do ((ptr1 x (cdr ptr1))
(ptr2 (cdr x) (cdr ptr2)))
((or (null? ptr2)
(not (test (car x) (car ptr2))))
(set-cdr! ptr1 nil)
(merge-list x (merge-sort ptr2))))))