aboutsummaryrefslogtreecommitdiffstats
path: root/strings.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-01-11 22:01:23 -0800
committerRose Hogenson <rhogenson@posteo.net>2022-01-11 22:01:23 -0800
commit68986fe0410584c6934c835bb0ee784655f5f8c5 (patch)
treed51bc2f3e09df35ef81b7a0c462ff555b4344701 /strings.csc
parentAdd a first implementation of a macro expander. (diff)
downloadchromatopelma-68986fe0410584c6934c835bb0ee784655f5f8c5.tar.zst
Move scheme compiler into a separate directory.
Diffstat (limited to 'strings.csc')
-rw-r--r--strings.csc46
1 files changed, 0 insertions, 46 deletions
diff --git a/strings.csc b/strings.csc
deleted file mode 100644
index 737c91b..0000000
--- a/strings.csc
+++ /dev/null
@@ -1,46 +0,0 @@
-(define-library (csc strings)
- (export
- find
- join
- not-found-error?
- prefix?
- str-quote)
- (import (scheme base)
- (only (scheme case-lambda) case-lambda)
- (only (scheme write) write)
- (only (csc list) intercalate))
- (begin
-
-
- (define prefix?
- (case-lambda
- ((prefix str) (prefix? prefix str 0))
- ((prefix str start)
- (and (<= (string-length prefix) (- (string-length str) start))
- (string=? prefix (substring str start (+ start (string-length prefix))))))))
-
-
- (define (str-quote s)
- (let ((out (open-output-string)))
- (write s out)
- (get-output-string out)))
-
-
- (define-record-type <not-found-error>
- (make-not-found-error)
- not-found-error?)
-
-
- (define find
- (case-lambda
- ((match str) (find match str 0 (string-length str)))
- ((match str start) (find match str start (string-length str)))
- ((match str start end)
- (let loop ((i start))
- (cond ((>= i end) (raise (make-not-found-error)))
- ((prefix? match str i) i)
- (else (loop (+ 1 i))))))))
-
-
- (define (join sep . strings)
- (apply string-append (intercalate sep strings)))))