vector-copy now works for empty vectors

svn: r16930
This commit is contained in:
Robby Findler 2009-11-20 22:43:01 +00:00
parent 2a7664eba8
commit 7b6eb65d79

View File

@ -20,19 +20,29 @@
(unless (exact-nonnegative-integer? start) (unless (exact-nonnegative-integer? start)
(raise-type-error 'vector-copy "non-negative exact integer" 1 start)) (raise-type-error 'vector-copy "non-negative exact integer" 1 start))
(let ([len (vector-length v)]) (let ([len (vector-length v)])
(unless (and (<= 0 start) (< start len)) (cond
(raise-mismatch-error [(= len 0)
'vector-copy (unless (and (= start 0)
(format "start index ~e out of range [~e, ~e] for vector ~e" (= end 0))
start 0 len v) (raise-mismatch-error
v)) 'vector-copy
(unless (and (<= start end) (<= end len)) (format "start index and end index must both be 0 for empty vectors, got ~e and ~e"
(raise-mismatch-error start len)))
'vector-copy (vector)]
(format "end index ~e out of range [~e, ~e] for vector ~e" [else
end start len v) (unless (and (<= 0 start) (< start len))
v)) (raise-mismatch-error
(vector-copy* v start end))) 'vector-copy
(format "start index ~e out of range [~e, ~e] for vector ~e"
start 0 len v)
v))
(unless (and (<= start end) (<= end len))
(raise-mismatch-error
'vector-copy
(format "end index ~e out of range [~e, ~e] for vector ~e"
end start len v)
v))
(vector-copy* v start end)])))
;; do vector-map, putting the result in `target' ;; do vector-map, putting the result in `target'
;; length is passed to save the computation ;; length is passed to save the computation