;; Personal library catalog system ofr NOVELS ;; All information for a book is stored on the plist of the book ;; ;; Notes: ;; ;; 1. Book names will be symbols -- e.g., pride-and-prejudice ;; 2. Author names will be strings -- e.g., "Jane Austin" ;; 3. Dates will be integers -- e.g., 1813 ;; 4. Genres will be strings -- e.g., "comedy of manners" ;; The catalog is a global variable (setf *catalog* ()) ; This function adds a book (a symbol which is loaded with ; properties) to the catalog (defun add (title author1 date1 genre1) (setf (get title 'author) author1) (setf (get title 'date) date1) (setf (get title 'genre) genre1) (setf *catalog* (cons title *catalog*)) ) ; Three simple referencers (defun author (title) (get title 'author) ) (defun date (title) (get title 'date) ) (defun genre (title) (get title 'genre) ) ; This function displays the catalog in the form of "crude" plists. (defun dump-holdings () (mapcar #'symbol-plist *catalog*) ) ; This function displays the catalog in a nice format (defun display-holdings () (display-holdings2 *catalog*) ) ; helper function for the function above (defun display-holdings2 (l &aux item) (cond ((null l) t ) (t (setf item (car l)) (format t "Title: ~A Author: ~A Date: ~A Genre: ~A" item (author item) (date item) (genre item)) (terpri) (display-holdings2 (cdr l)) ) ) )