我开始通过 Practical 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 不够好,无法进行故障排除。这本书说我应该得到数据库中所有记录的列表。出了什么问题?