* moved vector-ref and vector-set! to ikarus.vectors

This commit is contained in:
Abdulaziz Ghuloum 2007-05-05 05:17:43 -04:00
parent 71ca0c1e06
commit d09192f506
3 changed files with 30 additions and 27 deletions

Binary file not shown.

View File

@ -69,30 +69,6 @@
ls
(f x (cdr ls)))))))
(primitive-set! 'vector-ref
(lambda (v i)
(unless (vector? v)
(error 'vector-ref "~s is not a vector" v))
(unless (fixnum? i)
(error 'vector-ref "~s is not a valid index" i))
(unless (and ($fx< i ($vector-length v))
($fx<= 0 i))
(error 'vector-ref "index ~s is out of range for ~s" i v))
($vector-ref v i)))
(primitive-set! 'vector-set!
(lambda (v i c)
(unless (vector? v)
(error 'vector-set! "~s is not a vector" v))
(unless (fixnum? i)
(error 'vector-set! "~s is not a valid index" i))
(unless (and ($fx< i ($vector-length v))
($fx<= 0 i))
(error 'vector-set! "index ~s is out of range for ~s" i v))
($vector-set! v i c)))
(primitive-set! 'vector
;;; FIXME: add case-lambda

View File

@ -1,10 +1,11 @@
(library (ikarus vectors)
(export make-vector vector-length)
(export make-vector vector-length vector-ref vector-set!)
(import
(except (ikarus) make-vector vector-length)
(except (ikarus) make-vector vector-length vector-ref
vector-set!)
(only (scheme)
$fx= $fx>= $fx+ $vector-set!
$fx= $fx>= $fx< $fx<= $fx+ $vector-set! $vector-ref
$make-vector $vector-length))
@ -30,4 +31,30 @@
(error 'make-vector "~s is not a valid length" n))
(fill! ($make-vector n) 0 n fill)])))
(define vector-ref
(lambda (v i)
(unless (vector? v)
(error 'vector-ref "~s is not a vector" v))
(unless (fixnum? i)
(error 'vector-ref "~s is not a valid index" i))
(unless (and ($fx< i ($vector-length v))
($fx<= 0 i))
(error 'vector-ref "index ~s is out of range for ~s" i v))
($vector-ref v i)))
(define vector-set!
(lambda (v i c)
(unless (vector? v)
(error 'vector-set! "~s is not a vector" v))
(unless (fixnum? i)
(error 'vector-set! "~s is not a valid index" i))
(unless (and ($fx< i ($vector-length v))
($fx<= 0 i))
(error 'vector-set! "index ~s is out of range for ~s" i v))
($vector-set! v i c)))
)