使用全局变量 *db*,来保存数据
(defvar *db* nil)
(defun make-cd (title artist rating ripped)
(list :title title :artits artist :rating rating :ripped ripped)
)
(defun add-record (cd)
( push cd *db*)
)
CL-USER> (add-record (make-cd "Roses" "Kathy" 7 t))
((:TITLE "Roses" :ARTITS "Kathy" :RATING 7 :RIPPED T))
CL-USER> (add-record (make-cd "Lily" "Pgy" 8 t))
((:TITLE "Lily" :ARTITS "Pgy" :RATING 8 :RIPPED T) (:TITLE "Roses" :ARTITS "Kathy" :RATING 7 :RIPPED T))
CL-USER> (add-record (make-cd "Kly" "Gy" 9 t))
((:TITLE "Kly" :ARTITS "Gy" :RATING 9 :RIPPED T) (:TITLE "Lily" :ARTITS "Pgy" :RATING 8 :RIPPED T) (:TITLE "Roses" :ARTITS "Kathy" :RATING 7 :RIPPED T))
#查看*DB*中的数据
CL-USER> *DB*
((:TITLE "Kly" :ARTITS "Gy" :RATING 9 :RIPPED T) (:TITLE "Lily" :ARTITS "Pgy" :RATING 8 :RIPPED T) (:TITLE "Roses" :ARTITS "Kathy" :RATING 7 :RIPPED T))