optional argument for make-array

This commit is contained in:
Yuichi Nishiwaki 2014-07-15 22:27:48 +09:00
parent 4f5a92d921
commit 318475c14b
1 changed files with 6 additions and 1 deletions

View File

@ -34,7 +34,12 @@
(set-array-size! ary size)))
(define (make-array . rest)
(create-array (vector) 0 0 0))
(if (null? rest)
(make-array 0)
(let ((capacity (car rest))
(ary (create-array (vector) 0 0 0)))
(array-reserve! ary capacity)
ary)))
(define (array-ref ary i)
(let ((data (array-data ary)))