My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
; returns a new vector with the elements of `lst` attached to the end of `v`. Do this without using vector->list, list->vector, and append.
(define vector-append-list
(lambda (v lst)
(vector-append-list2 v lst (make-vector (+ (vector-length v) (length lst))) 0)))

(define vector-append-list2
(lambda (v lst newV i)
(if (< i (vector-length v))
(let ((sidefx (vector-set! newV i (vector-ref v i))))
(vector-append-list2 v lst newV (+ i 1)))
(if (not (null? lst))
(let ((sidefx (vector-set! newV i (car lst))))
(vector-append-list2 v (cdr lst) newV (+ i 1)))
newV))))



(vector-append-list '#(1 2 3) '(4 5))
; #(1 2 3 4 5)

Change log

r2 by jonathan.hefner on Jun 8, 2008   Diff
Initial commit
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 716 bytes, 19 lines
Powered by Google Project Hosting