New to Common Lisp and can't understand why the defun function is not working in simple case

231 views Asked by At

In Chapter 3 of "Practical Common Lisp," we are asked to create a CD database by creating the function make-cd which is defined as follows:

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

Within my REPL (using SLIME) this seems to go according to plan... until I come to add a value to the database, e.g.

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

Then I get the following error message

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

This code is character-for-character what is written in the book and there is no note to explain the error, or what this error means.

I am new to Lisp and have no idea what has gone wrong here!

1

There are 1 answers

0
eMBee On

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.