Skip to content

Instantly share code, notes, and snippets.

@ldunn
Created November 7, 2009 00:07
Show Gist options
  • Select an option

  • Save ldunn/228403 to your computer and use it in GitHub Desktop.

Select an option

Save ldunn/228403 to your computer and use it in GitHub Desktop.
(defun cddb-entry(title artist rating)
(list :title title :artist artist :rating rating))
(defvar *db* nil)
(defun add-record (cd) (push cd *db*))
(defun dump-db ()
(dolist (cd *db*)
(format t "~{~a:~10t~a~%~}~%" cd )))
(defun prompt-read (prompt)
(format *query-io* "~a: " prompt)
(force-output *query-io*)
(read-line *query-io*))
(defun make-prompt-for-cd ()
(add-record
( cddb-entry
(prompt-read "Title")
(prompt-read "Artist")
(or(parse-integer(prompt-read "Rating") :junk-allowed t) 0))))
(defun save-db (filename)
(with-open-file (out filename
:direction :output
:if-exists :supersede)
(with-standard-io-syntax
(print *db* out))))
(defun load-db (filename)
(with-open-file (in filename)
(with-standard-io-syntax
(setf *db* (read in)))))
(defun select-by-artist (artist)
(remove-if-not
#'(lamba (cd) (equal (getf cd :artist) artist))
*db))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment