adhalanay
adhalanay

Reputation: 149

deftype - variable unbound

I am trying to learn Common Lisp following C. Shapiro's Common Lisp: An interactive approach. I try to define the type bstree from chapter 18. My code is the following

(defun elementp (e)
  (or (characterp e) (numberp e) (packagep e)))
(deftype element ()
  '(satisfies elementp))
(defun bstreep (tree)
  (or (typep tree element)
      (and (listp tree)
           (= (length tree) 3)
           (typep (first tree) element))))

When I feed it to slime it gives the error Undefined variable:ELEMENT. What is wrong and how can I define the bstreep function?

Upvotes: 0

Views: 107

Answers (1)

Diego Sevilla
Diego Sevilla

Reputation: 29021

Have you tried to use the quoted form this way in all the typep usages?:

(typep tree 'element)

Upvotes: 4

Related Questions