diff --git a/src/ikarus.boot b/src/ikarus.boot index c5487f8..fcc9f15 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/ikarus.core.ss b/src/ikarus.core.ss index 5113723..f842dbe 100644 --- a/src/ikarus.core.ss +++ b/src/ikarus.core.ss @@ -70,27 +70,6 @@ (error 'vector-length "~s is not a vector" x)) ($vector-length x))) -(let () - (define fill! - (lambda (s i n c) - (cond - [($fx= i n) s] - [else - ($string-set! s i c) - (fill! s ($fx+ i 1) n c)]))) - (define make-string - (case-lambda - [(n) - (unless (and (fixnum? n) (fx>= n 0)) - (error 'make-string "~s is not a valid length" n)) - ($make-string n)] - [(n c) - (unless (and (fixnum? n) (fx>= n 0)) - (error 'make-string "~s is not a valid length" n)) - (unless (char? c) - (error 'make-string "~s is not a character" c)) - (fill! ($make-string n) 0 n c)])) - (primitive-set! 'make-string make-string)) (primitive-set! 'string-length diff --git a/src/ikarus.strings.ss b/src/ikarus.strings.ss index b6e06fc..5458773 100644 --- a/src/ikarus.strings.ss +++ b/src/ikarus.strings.ss @@ -1,9 +1,11 @@ (library (ikarus strings) - (export string-ref) + (export string-ref make-string) (import - (except (ikarus) string-ref) - (only (scheme) $string-ref $fx<= $fx< $string-length)) + (except (ikarus) string-ref make-string) + (only (scheme) $string-ref $fx+ $fx= $fx<= $fx< $string-length + $make-string $string-set!)) + (define (string-ref s i) (unless (string? s) (error 'string-ref "~s is not a string" s)) @@ -12,4 +14,29 @@ (unless (and ($fx< i ($string-length s)) ($fx<= 0 i)) (error 'string-ref "index ~s is out of range for ~s" i s)) - ($string-ref s i))) + ($string-ref s i)) + + + (define make-string + (let () + (define fill! + (lambda (s i n c) + (cond + [($fx= i n) s] + [else + ($string-set! s i c) + (fill! s ($fx+ i 1) n c)]))) + (define make-string + (case-lambda + [(n) + (unless (and (fixnum? n) (fx>= n 0)) + (error 'make-string "~s is not a valid length" n)) + ($make-string n)] + [(n c) + (unless (and (fixnum? n) (fx>= n 0)) + (error 'make-string "~s is not a valid length" n)) + (unless (char? c) + (error 'make-string "~s is not a character" c)) + (fill! ($make-string n) 0 n c)])) + make-string)) + )