diff --git a/src/ikarus.boot b/src/ikarus.boot index c00be11..8d3da4e 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 a5e4b86..73b8df4 100644 --- a/src/ikarus.core.ss +++ b/src/ikarus.core.ss @@ -70,24 +70,6 @@ (f x (cdr ls))))))) -(primitive-set! 'vector - ;;; FIXME: add case-lambda - (letrec ([length - (lambda (ls n) - (cond - [(null? ls) n] - [else (length ($cdr ls) ($fx+ n 1))]))] - [loop - (lambda (v ls i n) - (cond - [($fx= i n) v] - [else - ($vector-set! v i ($car ls)) - (loop v ($cdr ls) ($fx+ i 1) n)]))]) - (lambda ls - (let ([n (length ls 0)]) - (let ([v (make-vector n)]) - (loop v ls 0 n)))))) (primitive-set! 'list? diff --git a/src/ikarus.vectors.ss b/src/ikarus.vectors.ss index 8c1ff5d..ce8a412 100644 --- a/src/ikarus.vectors.ss +++ b/src/ikarus.vectors.ss @@ -1,12 +1,12 @@ (library (ikarus vectors) - (export make-vector vector-length vector-ref vector-set!) + (export make-vector vector vector-length vector-ref vector-set!) (import - (except (ikarus) make-vector vector-length vector-ref - vector-set!) + (except (ikarus) make-vector vector + vector-length vector-ref vector-set!) (only (scheme) - $fx= $fx>= $fx< $fx<= $fx+ $vector-set! $vector-ref - $make-vector $vector-length)) + $fx= $fx>= $fx< $fx<= $fx+ $car $cdr + $vector-set! $vector-ref $make-vector $vector-length)) (define vector-length @@ -31,6 +31,27 @@ (error 'make-vector "~s is not a valid length" n)) (fill! ($make-vector n) 0 n fill)]))) + + (define vector + ;;; FIXME: add case-lambda + (letrec ([length + (lambda (ls n) + (cond + [(null? ls) n] + [else (length ($cdr ls) ($fx+ n 1))]))] + [loop + (lambda (v ls i n) + (cond + [($fx= i n) v] + [else + ($vector-set! v i ($car ls)) + (loop v ($cdr ls) ($fx+ i 1) n)]))]) + (lambda ls + (let ([n (length ls 0)]) + (let ([v (make-vector n)]) + (loop v ls 0 n)))))) + + (define vector-ref (lambda (v i) (unless (vector? v)