Q:

common lisp programming EQ error

I am getting an error "variable EQ has no value" when I run the following code. How to overcome this error?
(defun add_book(bookref title author publisher)
  (setf (get bookref 'title) title)
  (setf (get bookref 'author) author)
  (setf (get bookref 'publisher) publisher)
  (setq library (cons bookref library))
  bookref)

(defun retrieve_by (property value)
  (setq result nil)
  (do  ((L library (cdr L)))
      ((NULL L) result)
    (cond (EQ (get (car L) property) value)
          (cons (car L) result))))

A:

Maybe better formatting and the output from the SBCL compiler will help you. See the compiler warnings. Try to consult the Lisp reference to look up the syntax of the various constructs: http://lispdoc.com
* (defun add_book(bookref title author publisher)
  (setf (get bookref 'title) title)
  (setf (get bookref 'author) author)
  (setf (get bookref 'publisher) publisher)
  (setq library (cons bookref library))
  bookref)
; in: DEFUN ADD_BOOK
;     (SETQ LIBRARY (CONS BOOKREF LIBRARY))
; 
; caught WARNING:
;   undefined variable: LIBRARY
; 
; compilation unit finished
;   Undefined variable:
;     LIBRARY
;   caught 1 WARNING condition

ADD_BOOK
* (defun retrieve_by (property value)
  (setq result nil)
  (do  ((L library (cdr L)))
      ((NULL L) result)
    (cond (EQ (get (car L) property) value)
          (cons (car L) result))))

; in: DEFUN RETRIEVE_BY
;     (COND (EQ (GET (CAR L) PROPERTY) VALUE) (CONS (CAR L) RESULT))
; --> IF COND 
; ==>
;   (IF CONS
;       (PROGN (CAR L) RESULT)
;       NIL)
; 
; caught WARNING:
;   undefined variable: CONS

; ==>
;   (IF EQ
;       (PROGN (GET (CAR L) PROPERTY) VALUE)
;       (COND (CONS (CAR L) RESULT)))
; 
; caught WARNING:
;   undefined variable: EQ

;     (DO ((L LIBRARY (CDR L)))
;         ((NULL L) RESULT)
;       (COND (EQ (GET (CAR L) PROPERTY) VALUE) (CONS (CAR L) RESULT)))
; --> BLOCK 
; ==>
;   (LET ((L LIBRARY))
;     (TAGBODY
;       (GO #:G1)
;      #:G0
;       (TAGBODY (COND (EQ # VALUE) (CONS # RESULT)))
;       (PSETQ L (CDR L))
;      #:G1
;       (UNLESS (NULL L) (GO #:G0))
;       (RETURN-FROM NIL (PROGN RESULT))))
; 
; caught WARNING:
;   undefined variable: LIBRARY

;     (SETQ RESULT NIL)
; 
; caught WARNING:
;   undefined variable: RESULT
; 
; compilation unit finished
;   Undefined variables:
;     CONS EQ LIBRARY RESULT
;   caught 4 WARNING conditions

RETRIEVE_BY
* 

