add vector-copy and vector-copy!

This commit is contained in:
Yuichi Nishiwaki 2013-11-17 02:31:32 +09:00
parent 1ef3ed91a2
commit 0690fbbdb4
1 changed files with 19 additions and 0 deletions

View File

@ -385,6 +385,25 @@
v) v)
(vector-set! v i (car l)))))) (vector-set! v i (car l))))))
(define (vector-copy! to at from . opts)
(let ((start (if (pair? opts) (car opts) 0))
(end (if (>= (length opts) 2)
(cadr opts)
(vector-length from))))
(do ((i at (+ i 1))
(j start (+ j 1)))
((< j end))
(vector-set! to i (vector-ref from j)))))
(define (vector-copy v . opts)
(let ((start (if (pair? opts) (car opts) 0))
(end (if (>= (length opts) 2)
(cadr opts)
(vector-length v))))
(let ((res (make-vector (vector-length v))))
(vector-copy! res 0 v start end)
res)))
;;; 6.9 bytevector ;;; 6.9 bytevector
(define (bytevector . objs) (define (bytevector . objs)