Changeset 29954 in project for release/4/r7rs/trunk/scheme.base.scm


Ignore:
Timestamp:
10/25/13 00:08:28 (8 years ago)
Author:
evhan
Message:

r7rs: Extended-arity char*? and string*? comparators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/r7rs/trunk/scheme.base.scm

    r29599 r29954  
    11(module scheme.base ()
    22
    3 (import (except scheme syntax-rules cond-expand member))
     3(import (except scheme syntax-rules cond-expand
     4                       assoc list-set! list-tail member
     5                       char=? char<? char>? char<=? char>=?
     6                       string=? string<? string>? string<=? string>=?))
     7(import (prefix (only scheme char=? char<? char>? char<=? char>=?
     8                             string=? string<? string>? string<=? string>=?)
     9                %))
    410(import (except chicken with-exception-handler raise quotient remainder modulo))
    511(import numbers)
     
    223229
    224230;;;
     231;;; 6.6 Characters
     232;;;
     233
     234(define-syntax define-extended-arity-comparator
     235  (syntax-rules ()
     236    ((_ name comparator check-type)
     237     (define name
     238       (let ((cmp comparator))
     239         (lambda (o1 o2 . os)
     240           (check-type o1 'name)
     241           (let lp ((o1 o1) (o2 o2) (os os) (eq #t))
     242             (check-type o2 'name)
     243             (if (null? os)
     244                 (and eq (cmp o1 o2))
     245                 (lp o2 (car os) (cdr os) (and eq (cmp o1 o2)))))))))))
     246
     247(: char=? (char char #!rest char -> boolean))
     248(: char<? (char char #!rest char -> boolean))
     249(: char>? (char char #!rest char -> boolean))
     250(: char<=? (char char #!rest char -> boolean))
     251(: char>=? (char char #!rest char -> boolean))
     252
     253(define-extended-arity-comparator char=? %char=? ##sys#check-char)
     254(define-extended-arity-comparator char>? %char>? ##sys#check-char)
     255(define-extended-arity-comparator char<? %char<? ##sys#check-char)
     256(define-extended-arity-comparator char<=? %char<=? ##sys#check-char)
     257(define-extended-arity-comparator char>=? %char>=? ##sys#check-char)
     258
     259;;;
     260;;; 6.7 Strings
     261;;;
     262
     263(: string=? (string string #!rest string -> boolean))
     264(: string<? (string string #!rest string -> boolean))
     265(: string>? (string string #!rest string -> boolean))
     266(: string<=? (string string #!rest string -> boolean))
     267(: string>=? (string string #!rest string -> boolean))
     268
     269(define-extended-arity-comparator string=? %string=? ##sys#check-string)
     270(define-extended-arity-comparator string<? %string<? ##sys#check-string)
     271(define-extended-arity-comparator string>? %string>? ##sys#check-string)
     272(define-extended-arity-comparator string<=? %string<=? ##sys#check-string)
     273(define-extended-arity-comparator string>=? %string>=? ##sys#check-string)
     274
     275;;;
    225276;;; 6.11. Exceptions
    226277;;;
Note: See TracChangeset for help on using the changeset viewer.