This commit is contained in:
Gregory Tertyshny 2017-05-30 16:25:12 +03:00
parent cb811007c9
commit 0bda960f26
2 changed files with 22 additions and 9 deletions

BIN
carnifex.pdf Normal file

Binary file not shown.

31
dbms.cl
View file

@ -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*)))