Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. (defun address-of (array &rest indices)
  3. (make-array 1 :element-type (array-element-type array)
  4. :displaced-to array
  5. :displaced-index-offset (if indices
  6. (reduce (function *) indices)
  7. 0)))
  8.  
  9. (defun deref (address) (aref address 0))
  10. (defun (setf deref) (new-value address) (setf (aref address 0) new-value))
  11.  
  12. (let* ((array (vector 1 2 3 4))
  13. (pointer (address-of array 2)))
  14. (incf (deref pointer) 100)
  15. array)
  16. --> #(1 2 103 4)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement