0

在“Practical Common Lisp”的第 3 章中,我们被要求通过创建函数来创建 CD 数据库,函数make-cd定义如下:

(defun make-cd (title artist rating ripped)
  (list :title title :artist artist :rating rating :ripped ripped))

在我的 REPL(使用 SLIME)中,这似乎按计划进行......直到我向数据库添加一个值,例如

(make-cd "Roses" "Kathy Mattea" 7 t)
(:TITLE "Roses" :ARTIST "Kathy Mattea" :RATING 7 :RIPPED T)

然后我收到以下错误消息

Undefined function :TITLE called with arguments ("Roses"
                                             :ARTIST
                                             "Kathy Mattea"
                                             :RATING
                                             7
                                             :RIPPED
                                             T) .
   [Condition of type CCL::UNDEFINED-FUNCTION-CALL]

此代码是书中所写的逐个字符,没有注释来解释错误或此错误的含义。

我是 Lisp 新手,不知道这里出了什么问题!

4

1 回答 1

7

in the book the instruction to add an entry to the database is:

CL-USER> (make-cd "Roses" "Kathy Mattea" 7 t)

CL-USER> is the prompt of the REPL, followed by your input.

the line that follows is does not start with a prompt and indicates the output that the function call returns:

(:TITLE "Roses" :ARTIST "Kathy Mattea" :RATING 7 :RIPPED T)

you should only enter the first line, then verify that the output you get matches the second line.

于 2018-12-15T14:08:38.807 回答