Created
November 7, 2009 00:07
-
-
Save ldunn/228403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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