Last active
January 5, 2019 00:15
-
-
Save emdeesee/a6d0981fb53a35850d9b08393d4183f2 to your computer and use it in GitHub Desktop.
Functionality like Python's ChainMap in Common Lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun make-chain-table (&rest tables) | |
(lambda (key) | |
(labels ((aux (tables) | |
(if (null tables) | |
(values nil nil) | |
(multiple-value-bind (value found) (gethash key (car tables)) | |
(if found | |
(values value t) | |
(aux (cdr tables))))))) | |
(aux tables)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage