aboutsummaryrefslogtreecommitdiffstats
path: root/lib/csc/sort.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2023-05-01 07:56:42 -0700
committerRose Hogenson <rhogenson@posteo.net>2023-05-01 07:56:42 -0700
commita89d6c82e981fec7d6e4c975e083d2b9e04467ad (patch)
treed5445ceb797473dd45ac006c337d990e5dd6f0d4 /lib/csc/sort.csc
parentFix bugs with recursive macros and empty template. (diff)
downloadchromatopelma-a89d6c82e981fec7d6e4c975e083d2b9e04467ad.tar.zst
Rewrite most of the compiler.
This represents a major step back in terms of functionality, and amount of code. The latter I think constitutes a major win. Next steps are to reimplement syntax-rules, call/cc, and call-with-values.
Diffstat (limited to 'lib/csc/sort.csc')
-rw-r--r--lib/csc/sort.csc28
1 files changed, 0 insertions, 28 deletions
diff --git a/lib/csc/sort.csc b/lib/csc/sort.csc
deleted file mode 100644
index 6be1e16..0000000
--- a/lib/csc/sort.csc
+++ /dev/null
@@ -1,28 +0,0 @@
-(define-library (csc sort)
- (export sort)
- (import (scheme base)
- (only (csc list)
- revappend
- split-at))
- (begin
-
-
- (define (sort-len cmp xs len)
- (if (<= len 1)
- xs
- (let ((n/2 (truncate-quotient len 2)))
- (let-values (((half-a half-b) (split-at n/2 xs)))
- (let ((sorted-half-a (sort-len cmp half-a n/2))
- (sorted-half-b (sort-len cmp half-b (- len n/2))))
- (let loop ((a sorted-half-a)
- (b sorted-half-b)
- (acc '()))
- (cond ((null? a) (revappend acc b))
- ((null? b) (revappend acc a))
- ((cmp (car b) (car a))
- (loop a (cdr b) (cons (car b) acc)))
- (else (loop (cdr a) b (cons (car a) acc))))))))))
-
-
- (define (sort cmp xs)
- (sort-len cmp xs (length xs)))))