From: Sam S. <sd...@gn...> - 2012-06-18 14:50:35
|
> * Yves S. Garret <lbh...@tz...> [2012-06-17 14:20:13 -0400]: >> > 1) how *db* is accessed, that's where all the data is held and (defun select (selector-fn) (remove-if-not selector-fn *db*)) (defun where (&key title artist rating (ripped nil ripped-p)) #'(lambda (cd) (and (if title (equal (getf cd :title) title) t) (if artist (equal (getf cd :artist) artist) t) (if rating (equal (getf cd :rating) rating) t) (if ripped-p (equal (getf cd :ripped) ripped) t)))) SELECT returns elements of *DB* which satisfy SELECTOR-FN WHERE returns a function which __APPARENTLY__ can be used as an argument to SELECT. e.g., (select (where :title "foo")) will return the objects with the given title. > 2) what the heck is &key? a lambda list keyword. http://www.lispworks.com/documentation/HyperSpec/Body/03_da.htm it is a way to pass optional arguments to functions in a position independent way. e.g.: (defun foo (&key (a 1) (b 2) (c 3)) (list a b c)) (foo :b 10) => (1 10 3) (foo :a 4 :c 5) => (4 2 5) (foo :c 5 :a 4) => (4 2 5) > If I'm missing something absurdly obvious, please feel free to point it out. You might get a more detailed and informative reply to such a general Lisp question on the comp.lang.lisp newsgroup. -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://jihadwatch.org http://openvotingconsortium.org http://iris.org.il http://palestinefacts.org http://mideasttruth.com Democrats, get out of my wallet! Republicans, get out of my bedroom! |