Browse files

Changed the array to lie inside a list. This layer of indirection all…

…ows you to

change it in place.
  • Loading branch information...
smithzvk committed Jun 14, 2011
1 parent 9c7a447 commit 449d37c90ca00319c6a5eab27460bce606ccf2bd
Showing with 10 additions and 4 deletions.
  1. +10 −4 versioned-arrays.lisp
@@ -15,14 +15,20 @@
"Make a versioned array."
(when (or adjustable fill-pointer displaced-to displaced-index-offset)
(error "The capabilities: adjustable, fill-pointer, displaced-to, displaced-index-offset are not implemented yet") )
- (apply #'make-array dimensions args) )
+ (list (apply #'make-array dimensions args)) )
+;; Basically this works like this. A versioned array is a list whose last
+;; element is an array. When you access a value from the array, the array moves
+;; to the first element of the list (making it a list of length 1) while at the
+;; same time reversing the element of the list after it while reversing the
+;; delta at the same time.
(defun varef (v-arr &rest idx)
- (if (consp v-arr)
+ (if (arrayp (car v-arr))
+ (apply #'aref (car v-arr) idx)
(if (equal (rest (first v-arr)) idx)
(first (first v-arr))
- (varef (rest v-arr)) )
- (apply #'aref v-arr idx) ))
+ (varef (rest v-arr)) )))
(define-modf-function varef 1 (new-val v-arr &rest idx)
(cons (cons new-val idx) v-arr) )

0 comments on commit 449d37c

Please sign in to comment.