一个简单的 CD 数据库
创建CD
(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped ripped))
全局变量 holder
(defvar *db* nil)
(defun add-record (cd) (push cd *db))
星号在 Lisp 中约定为全局变量
宏 push
查看
(defun dump-db()
(dolist (cd *db*)
(format t "~{~a:~10t~a~%~}~%" cd)))
宏 dolist
dolist 的简单用法
(dolist (item (list 1 2 3)) (format t "~a" item))
也可以
(format t "~{~a~}" (list 1 2 3))