From 0690fbbdb4f89499d053339f279b42998ba39a20 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 17 Nov 2013 02:31:32 +0900 Subject: [PATCH] add vector-copy and vector-copy! --- piclib/built-in.scm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/piclib/built-in.scm b/piclib/built-in.scm index eb38a8ed..98988950 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -385,6 +385,25 @@ v) (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 (define (bytevector . objs)