Start LISP

(defun ai-note(word)
  (format t word))

(ai-note "its ok for loading....! 100%")

(defun make-cd (title artist rating ripped)
       (list :title title :artist artist :rating rating :ripped ripped))
(defun add-record (cd) (push cd *cd-db*))
(defvar *cd-db* nil)
(defun dump-db ()
       (dolist (cd *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 prompt-for-cd ()
       (make-cd
        (prompt-read "Title")
        (prompt-read "Artist")
        (or (parse-integer (prompt-read "Rating") :junk-allowed t) 0)
        (y-or-n-p "Ripped [y/n] ")))
(defun add-cds ()
       (loop (add-record (prompt-for-cd))
          (if (not (y-or-n-p "Another? [y/n]: ")) (return))))
(defun save-db (filename)
       (with-open-file (out filename
                :direction :output
                :if-exists :supersede)
         (with-standard-io-syntax
           (print *cd-db* out))))
(defun load-db (filename)
       (with-open-file (in filename)
         (with-standard-io-syntax
           (setf *cd-db* (read in)))))

(add-record (make-cd "Roses" "Kathy Mattea" 9 t))
(add-record (make-cd "Fly" "Jack John" 23 t))
(add-record (make-cd "Dream" "Smith Willem" 4 t))
(add-record (make-cd "Room" "John Katte" 3 t))

(dump-db)

posted @ 2017-03-17 20:34  如夢亦如電  阅读(115)  评论(0)    收藏  举报