4 ms·
Common lisp has this universal setter-macro, SETF, which can be used to set values to all sorts of places. In this case you would use (setf (vref chip x y
by juki 9y ago
Common lisp has this universal setter-macro, SETF, which can be used to set values to all sorts of places.
In this case you would use
(setf (vref chip x y) new-value)
to call the function (just like with AREF above). Using SETF has the advantage that you can define "modify macros" that read and write a place. For example,
(incf (vref chip x y) delta)
would increment the place by DELTA. Or
(rotatef (vref chip x1 y1)
(vref chip x2 y2))
would swap two pixels.