I am trying to build a binary search tree in common lisp. I have defined the binary search class using the CLOS like this:
(defclass bst ()
((root :type node
:accessor tree-root
:initform nil
:initarg root)))
I am trying to define a generic function that takes in the tree object and a key and returns a boolean true if the tree contains the key and nil if the tree does not contain the key.
Right now I have the following definition of a generic function:
(defgeneric contains ((tree bst) (key))
(:documentation "returns boolean of whether the given tree contains a particular key)
I get the following error when I load the file into the REPL (I am using SBCL):
Required argument is not a symbol: (TREE BST)
Am I misunderstanding how generic functions work? I can't seem to define the function properly.
DEFGENERIC. - jkiiski<...> :initarg rootshould be<...>:initarg :root::rootshould be a keyword here. - mobiuseng