diff --git a/library/vector.lisp b/library/vector.lisp index 68a8a4a54..b39dabff6 100644 --- a/library/vector.lisp +++ b/library/vector.lisp @@ -8,7 +8,8 @@ (#:types #:coalton-library/types) (#:list #:coalton-library/list) (#:cell #:coalton-library/cell) - (#:iter #:coalton-library/iterator)) + (#:iter #:coalton-library/iterator) + (#:ram #:coalton-library/randomaccess)) (:export #:Vector #:new @@ -286,6 +287,20 @@ :initial-value init :from-end cl:t)))) + (define-instance (ram:RandomAccess (Vector :t) :t) + (define (ram:make n x) + (with-initial-element n x)) + (define (ram:length a) + (length a)) + (define (ram:readable? _) + True) + (define (ram:writable? _) + True) + (define (ram:unsafe-aref a n) + (index-unsafe n a)) + (define (ram:unsafe-set! a n x) + (set! n x a))) + (define-instance (Into (List :a) (Vector :a)) (define (into lst) (let ((out (with-capacity (list:length lst)))