我開始通過Practical Common LISP工作,第一個練習是編寫一個simple database。我在cygwin上使用GNU CLISP 2.48(2009-07-28)。麻煩格式化第一練習從實用常見LISP
此代碼,我已經對書幾次相比,不產生輸出的方式,書上說應該
(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以便排除故障。這本書說我應該得到數據庫中所有記錄的清單。出了什麼問題?
呃,我真傻!我花了15分鐘交叉檢查格式字符串。 – user151841