diff --git a/src/ikarus.boot b/src/ikarus.boot index faa1754..6cc2ce8 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/ikarus.chars.ss b/src/ikarus.chars.ss new file mode 100644 index 0000000..d719959 --- /dev/null +++ b/src/ikarus.chars.ss @@ -0,0 +1,195 @@ + +(library (ikarus chars) + (export char=? char? char>=?) + (import + (except (ikarus) char=? char? char>=?) + (only (scheme) + $car $cdr + $char= $char< $char<= $char> $char>=)) + + ;;; FIXME: this file is embarrasing + (define char=? + (let () + (define (err x) + (error 'char=? "~s is not a character" x)) + (case-lambda + [(c1 c2) + (if (char? c1) + (if (char? c2) + ($char= c1 c2) + (err c2)) + (err c1))] + [(c1 c2 c3) + (if (char? c1) + (if (char? c2) + (if (char? c3) + (and ($char= c1 c2) + ($char= c2 c3)) + (err c3)) + (err c2)) + (err c1))] + [(c1 . c*) + (if (char? c1) + (let f ([c* c*]) + (or (null? c*) + (let ([c2 ($car c*)]) + (if (char? c2) + (if ($char= c1 c2) + (f ($cdr c*)) + (let g ([c* ($cdr c*)]) + (if (null? c*) + #f + (if (char? ($car c*)) + (g ($cdr c*)) + (err ($car c*)))))) + (err c2))))) + (err c1))]))) + + (define char? + (let () + (define (err x) + (error 'char>? "~s is not a character" x)) + (case-lambda + [(c1 c2) + (if (char? c1) + (if (char? c2) + ($char> c1 c2) + (err c2)) + (err c1))] + [(c1 c2 c3) + (if (char? c1) + (if (char? c2) + (if (char? c3) + (and ($char> c1 c2) + ($char> c2 c3)) + (err c3)) + (err c2)) + (err c1))] + [(c1 . c*) + (if (char? c1) + (let f ([c1 c1] [c* c*]) + (or (null? c*) + (let ([c2 ($car c*)]) + (if (char? c2) + (if ($char> c1 c2) + (f c2 ($cdr c*)) + (let g ([c* ($cdr c*)]) + (if (null? c*) + #f + (if (char? ($car c*)) + (g ($cdr c*)) + (err ($car c*)))))) + (err c2))))) + (err c1))]))) + + (define char>=? + (let () + (define (err x) + (error 'char>=? "~s is not a character" x)) + (case-lambda + [(c1 c2) + (if (char? c1) + (if (char? c2) + ($char>= c1 c2) + (err c2)) + (err c1))] + [(c1 c2 c3) + (if (char? c1) + (if (char? c2) + (if (char? c3) + (and ($char>= c1 c2) + ($char>= c2 c3)) + (err c3)) + (err c2)) + (err c1))] + [(c1 . c*) + (if (char? c1) + (let f ([c1 c1] [c* c*]) + (or (null? c*) + (let ([c2 ($car c*)]) + (if (char? c2) + (if ($char>= c1 c2) + (f c2 ($cdr c*)) + (let g ([c* ($cdr c*)]) + (if (null? c*) + #f + (if (char? ($car c*)) + (g ($cdr c*)) + (err ($car c*)))))) + (err c2))))) + (err c1))]))) +) diff --git a/src/ikarus.core.ss b/src/ikarus.core.ss index 9f98144..32a0b4b 100644 --- a/src/ikarus.core.ss +++ b/src/ikarus.core.ss @@ -66,191 +66,11 @@ -(primitive-set! 'char=? - (let () - (define (err x) - (error 'char=? "~s is not a character" x)) - (case-lambda - [(c1 c2) - (if (char? c1) - (if (char? c2) - ($char= c1 c2) - (err c2)) - (err c1))] - [(c1 c2 c3) - (if (char? c1) - (if (char? c2) - (if (char? c3) - (and ($char= c1 c2) - ($char= c2 c3)) - (err c3)) - (err c2)) - (err c1))] - [(c1 . c*) - (if (char? c1) - (let f ([c* c*]) - (or (null? c*) - (let ([c2 ($car c*)]) - (if (char? c2) - (if ($char= c1 c2) - (f ($cdr c*)) - (let g ([c* ($cdr c*)]) - (if (null? c*) - #f - (if (char? ($car c*)) - (g ($cdr c*)) - (err ($car c*)))))) - (err c2))))) - (err c1))]))) -(primitive-set! 'char? - (let () - (define (err x) - (error 'char>? "~s is not a character" x)) - (case-lambda - [(c1 c2) - (if (char? c1) - (if (char? c2) - ($char> c1 c2) - (err c2)) - (err c1))] - [(c1 c2 c3) - (if (char? c1) - (if (char? c2) - (if (char? c3) - (and ($char> c1 c2) - ($char> c2 c3)) - (err c3)) - (err c2)) - (err c1))] - [(c1 . c*) - (if (char? c1) - (let f ([c1 c1] [c* c*]) - (or (null? c*) - (let ([c2 ($car c*)]) - (if (char? c2) - (if ($char> c1 c2) - (f c2 ($cdr c*)) - (let g ([c* ($cdr c*)]) - (if (null? c*) - #f - (if (char? ($car c*)) - (g ($cdr c*)) - (err ($car c*)))))) - (err c2))))) - (err c1))]))) -(primitive-set! 'char>=? - (let () - (define (err x) - (error 'char>=? "~s is not a character" x)) - (case-lambda - [(c1 c2) - (if (char? c1) - (if (char? c2) - ($char>= c1 c2) - (err c2)) - (err c1))] - [(c1 c2 c3) - (if (char? c1) - (if (char? c2) - (if (char? c3) - (and ($char>= c1 c2) - ($char>= c2 c3)) - (err c3)) - (err c2)) - (err c1))] - [(c1 . c*) - (if (char? c1) - (let f ([c1 c1] [c* c*]) - (or (null? c*) - (let ([c2 ($car c*)]) - (if (char? c2) - (if ($char>= c1 c2) - (f c2 ($cdr c*)) - (let g ([c* ($cdr c*)]) - (if (null? c*) - #f - (if (char? ($car c*)) - (g ($cdr c*)) - (err ($car c*)))))) - (err c2))))) - (err c1))]))) (primitive-set! '$memq (lambda (x ls) diff --git a/src/makefile.ss b/src/makefile.ss index 4fe68da..af2a16c 100755 --- a/src/makefile.ss +++ b/src/makefile.ss @@ -23,10 +23,11 @@ ;;; '("ikarus.handlers.ss" "ikarus.multiple-values.ss" - "ikarus.predicates.ss" - "ikarus.fixnums.ss" "ikarus.control.ss" "ikarus.collect.ss" + "ikarus.predicates.ss" + "ikarus.fixnums.ss" + "ikarus.chars.ss" "ikarus.records.ss" "ikarus.cxr.ss" "ikarus.strings.ss"