Advertisement
Guest User

gethashes

a guest
Mar 22nd, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. (defun gethashes (x &rest y) (dolist (z y x) (setf x (gethash z x))))
  2.  
  3. (defsetf gethashes (table key &rest more-keys) (new-value)
  4. (if (null more-keys)
  5. `(setf (gethash ,key ,table) ,new-value)
  6. `(setf (gethashes (gethash ,key ,table) ,@more-keys) ,new-value)))
  7.  
  8. (let ((table1 (make-hash-table))
  9. (table2 (make-hash-table)))
  10. (setf (gethash 'a table1) table2)
  11. (setf (gethashes table1 'a 14) 23)
  12. (gethashes table1 'a 14))
  13.  
  14. => 23
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement