Last active
August 29, 2015 13:57
-
-
Save 1ambda/9509007 to your computer and use it in GitHub Desktop.
lisp example
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 select (selector) | |
(remove-if-not selector *person-db*)) | |
(defun make-where-exprs (args) | |
(loop while args | |
collect `(equal (getf person ,(pop args)) ,(pop args)))) | |
(defmacro where (&rest args) | |
`#'(lambda (person) | |
(and ,@(make-where-exprs args)))) | |
;; CL-USER > (select (where :name "Hoon")) | |
;; ((:NAME "Hoon" :AGE 26 :ADDRESS "Seoul")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment