commit 81b00c17365d6f69db578ad3007fec3ab5c3f0eb
parent 1b4ea4f522287dcdd8a3a09c97d2dded83906975
Author: Jan P. Pasierb <me@janpasierb.com>
Date: Tue, 3 Jun 2025 00:43:07 +0100
Now ignoring compiled files + more progress one the book
Diffstat:
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1 +1,2 @@
*.swp
+*.fasl
diff --git a/mp3.fasl b/mp3.fasl
Binary files differ.
diff --git a/mp3.lisp b/mp3.lisp
@@ -41,14 +41,6 @@
(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))))
-
(defun update (selector-fn &key title artist rating (ripped nil ripped-p))
(setf *db*
(mapcar
@@ -63,3 +55,13 @@
(defun delete-rows (selector-fn)
(setf *db* (remove-if selector-fn *db*)))
+(defun make-comparison-expr (field value)
+ `(equal (getf cd ,field) ,value))
+
+(defun make-comparisons-list (fields)
+ (loop while fields
+ collecting (make-comparison-expr (pop fields) (pop fields))))
+
+(defmacro where (&rest clauses)
+ `#'(lambda (cd) (and ,@(make-comparisons-list clauses))))
+