* added (ikarus chars) library

* moved char=?, char<?, char<=?, char>?, and char>=? to the chars
 library.
This commit is contained in:
Abdulaziz Ghuloum 2007-05-05 04:45:13 -04:00
parent ffeff47eb4
commit 8fcc4e7d99
4 changed files with 198 additions and 182 deletions

Binary file not shown.

195
src/ikarus.chars.ss Normal file
View File

@ -0,0 +1,195 @@
(library (ikarus chars)
(export char=? char<? char<=? char>? char>=?)
(import
(except (ikarus) char=? char<? 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))])))
(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))])))
)

View File

@ -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! '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)

View File

@ -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"