diff --git a/src/ikarus.boot b/src/ikarus.boot index 5fcb497..058326f 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 d122886..8a16944 100644 --- a/src/ikarus.core.ss +++ b/src/ikarus.core.ss @@ -61,23 +61,6 @@ (primitive-set! x v) (set-top-level-value! x v))) - - - - - - - - - - - - - - - - - (primitive-set! 'string->symbol (lambda (x) (unless (string? x) @@ -147,38 +130,6 @@ (f ($symbol-plist x) '())))) -(let () - (define vector-loop - (lambda (x y i n) - (or ($fx= i n) - (and (equal? ($vector-ref x i) ($vector-ref y i)) - (vector-loop x y ($fxadd1 i) n))))) - (define string-loop - (lambda (x y i n) - (or ($fx= i n) - (and ($char= ($string-ref x i) ($string-ref y i)) - (string-loop x y ($fxadd1 i) n))))) - (define equal? - (lambda (x y) - (cond - [(eq? x y) #t] - [(pair? x) - (and (pair? y) - (equal? ($car x) ($car y)) - (equal? ($cdr x) ($cdr y)))] - [(vector? x) - (and (vector? y) - (let ([n ($vector-length x)]) - (and ($fx= n ($vector-length y)) - (vector-loop x y 0 n))))] - [(string? x) - (and (string? y) - (let ([n ($string-length x)]) - (and ($fx= n ($string-length y)) - (string-loop x y 0 n))))] - [(number? x) (and (number? y) (= x y))] - [else #f]))) - (primitive-set! 'equal? equal?)) diff --git a/src/ikarus.predicates.ss b/src/ikarus.predicates.ss index 27cf737..be42475 100644 --- a/src/ikarus.predicates.ss +++ b/src/ikarus.predicates.ss @@ -4,15 +4,16 @@ (export fixnum? flonum? bignum? number? complex? real? rational? integer? exact? eof-object? immediate? boolean? char? vector? string? procedure? null? pair? symbol? not - eq? eqv?) + eq? eqv? equal?) (import (except (ikarus) fixnum? flonum? bignum? number? complex? real? rational? integer? exact? eof-object? immediate? boolean? char? vector? string? procedure? null? - pair? symbol? not eq? eqv?) - + pair? symbol? not eq? eqv? equal?) + (only (scheme) $fxadd1 $vector-ref $fx= $char= $string-ref + $string-length $vector-length $car $cdr) (rename (only (ikarus) fixnum? flonum? bignum? eof-object? immediate? boolean? char? vector? string? procedure? null? pair? symbol? eq?) @@ -96,4 +97,39 @@ (lambda (x y) (or (sys:eq? x y) (and (number? x) (number? y) (= x y))))) + + + + (module (equal?) + (define vector-loop + (lambda (x y i n) + (or ($fx= i n) + (and (equal? ($vector-ref x i) ($vector-ref y i)) + (vector-loop x y ($fxadd1 i) n))))) + (define string-loop + (lambda (x y i n) + (or ($fx= i n) + (and ($char= ($string-ref x i) ($string-ref y i)) + (string-loop x y ($fxadd1 i) n))))) + (define equal? + (lambda (x y) + (cond + [(sys:eq? x y) #t] + [(pair? x) + (and (pair? y) + (equal? ($car x) ($car y)) + (equal? ($cdr x) ($cdr y)))] + [(vector? x) + (and (vector? y) + (let ([n ($vector-length x)]) + (and ($fx= n ($vector-length y)) + (vector-loop x y 0 n))))] + [(string? x) + (and (string? y) + (let ([n ($string-length x)]) + (and ($fx= n ($string-length y)) + (string-loop x y 0 n))))] + [(number? x) (and (number? y) (= x y))] + [else #f])))) + )