Created
November 13, 2015 10:28
-
-
Save AlejandroCatalina/7faaaee84cbda9884600 to your computer and use it in GitHub Desktop.
Lists comprehensions macro for lisp, and a pattern-matching macro
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 @ (value bind list test) | |
(let ((newlist (gensym))) | |
`(let ((,newlist nil)) | |
(dolist (,bind ,list) | |
(when ,test | |
(push ,value ,newlist))) | |
(nreverse ,newlist)))) | |
(defmacro pattern (bind l &rest body) | |
`(destructuring-bind ,bind ,l | |
,@body)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment