Created
August 31, 2010 01:19
-
-
Save kurohuku/558364 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defmacro with-assoc-values (binds alist &body body) | |
(let ((al (gensym "alist"))) | |
(flet ((expand-bind (bind) | |
`(,(first bind) | |
(cdr (assoc ,(second bind) ,al))))) | |
`(let ((,al ,alist)) | |
(let ,(mapcar #'expand-bind binds) | |
,@body))))) | |
;; (with-assoc-values ((a :hoge) (b :fuga)) `((:hoge . (3 4)) (:fuga . 4)) | |
;; (list a b)) | |
;; => ((3 4) 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment