diff --git a/carnifex.pdf b/carnifex.pdf new file mode 100644 index 0000000..918105b Binary files /dev/null and b/carnifex.pdf differ diff --git a/dbms.cl b/dbms.cl index 96df036..a954df6 100644 --- a/dbms.cl +++ b/dbms.cl @@ -1,11 +1,3 @@ -(defun hello () - (format t "hello, wordl!")) - - - -(defun list_test () - (getf (list :a 1 :b 2 :c 3) :a)) - (defvar *db* nil) (defun make-cd (title artist rating ripped) @@ -47,4 +39,25 @@ #'(lambda (cd) (equal (getf cd :artist) artist)) *db*)) -(format *query-io* "hello~%") +(defun select (selector-fn) + (remove-if-not selector-fn *db*)) + +(defun where (&key artist title 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 + #'(lambda (row) + (when (funcall selector-fn row) + (if title (setf (getf row :title) title)) + (if artist (setf (getf row :artist) artist)) + (if rating (setf (getf row :rating) rating)) + (if ripped-p (setf (getf row :ripped) ripped))) + row) + *db*)))