Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
130
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defun address-of (array &rest indices)
  2. (make-array 1 :element-type (array-element-type array)
  3. :displaced-to array
  4. :displaced-index-offset (if indices
  5. (loop
  6. :for i :in indices
  7. :for d :in (append (rest (array-dimensions array)) '(1))
  8. :for offset := (* i d) :then (* (+ offset i) d)
  9. :finally (return offset))
  10. 0)))
  11.  
  12. (defun deref (address) (aref address 0))
  13. (defun (setf deref) (new-value address) (setf (aref address 0) new-value))
  14.  
  15. (nth-value 1 (array-displacement (address-of (make-array '(5 4 3)) 1 1 1)))
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement