vector-copy now works for empty vectors
svn: r16930
This commit is contained in:
parent
2a7664eba8
commit
7b6eb65d79
|
@ -20,6 +20,16 @@
|
||||||
(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)])
|
||||||
|
(cond
|
||||||
|
[(= len 0)
|
||||||
|
(unless (and (= start 0)
|
||||||
|
(= end 0))
|
||||||
|
(raise-mismatch-error
|
||||||
|
'vector-copy
|
||||||
|
(format "start index and end index must both be 0 for empty vectors, got ~e and ~e"
|
||||||
|
start len)))
|
||||||
|
(vector)]
|
||||||
|
[else
|
||||||
(unless (and (<= 0 start) (< start len))
|
(unless (and (<= 0 start) (< start len))
|
||||||
(raise-mismatch-error
|
(raise-mismatch-error
|
||||||
'vector-copy
|
'vector-copy
|
||||||
|
@ -32,7 +42,7 @@
|
||||||
(format "end index ~e out of range [~e, ~e] for vector ~e"
|
(format "end index ~e out of range [~e, ~e] for vector ~e"
|
||||||
end start len v)
|
end start len v)
|
||||||
v))
|
v))
|
||||||
(vector-copy* v start end)))
|
(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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user