Aset2
Set the elements of a 2-dimensional array
Example Form:
(aset2 'delta1 a i j 27)
General Form:
(aset2 name alist i j val)
where name is a symbol, alist is a 2-dimensional array named
name, i and j are legal indices into alist, and val
is an arbitrary object. See arrays for details. Roughly speaking this
function ``modifies'' alist so that the value associated with (i
. j) is val. More precisely, it returns a new array, alist', of
the same name and dimension as alist that, under aref2, is
everywhere equal to alist except at (i . j) where the result is
val. That is, (aref2 name alist' x y) is (aref2 name alist x
y) for all legal indices x y except i and j where
(aref2 name alist' i j) is val.
In order to ``modify'' alist, aset2 conses a new pair
onto the front. If the length of the resulting alist exceeds the
:maximum-length entry in the array header, aset2
compresses the array as with compress2.
It is generally expected that the ``semantic value'' of name will be
alist (see arrays). This function operates in virtually constant
time whether this condition is true or not (unless the compress2
operation is required). But the value returned by this function cannot be
used efficiently by subsequent aset2 operations unless alist is the
semantic value of name when aset2 is executed. Thus, if the
condition is not true, aset2 prints a slow array warning to the
comment window. See slow-array-warning.
Function: aset2
(defun aset2 (name l i j val)
(declare (xargs :guard (and (array2p name l)
(integerp i)
(>= i 0)
(< i (car (dimensions name l)))
(integerp j)
(>= j 0)
(< j (cadr (dimensions name l))))))
(let ((l (cons (cons (cons i j) val) l)))
(cond ((> (length l) (maximum-length name l))
(compress2 name l))
(t l))))