我开始学习《实用的Common Lisp编程》一书,第一个练习是编写一个简单数据库。我在cygwin上使用GNU CLISP 2.48(2009-07-28)。
我已经多次对比了书中提供的代码,但输出结果与书中所述并不相符。
(defun make-cd (title artist rating ripped)
(list :title title :artist artist :rating rating :ripped))
(defvar *db* nil)
(defun add-record (cd) (push cd *db*))
(add-record (make-cd "Roses" "Kathy Mattea" 7 t))
(add-record (make-cd "Fly" "Dixie Chicks" 8 t))
(add-record (make-cd "Home" "Dixie Chicks" 9 t))
(defun dump-db ()
(dolist (cd *db*)
(format t "~{~a:~10t~a~%~}~%" cd)))
(dump-db)
我明白了
TITLE: Home
ARTIST: Dixie Chicks
RATING: 9
RIPPED:
*** - There are not enough arguments left for this format directive.
Current point in control string:
"~{~a:~10t~a~%~}~%"
|
我对
format
和LISP的理解不够深入,无法排除故障。书上说我应该得到数据库中所有记录的列表。出了什么问题?