Determine if a value appears in the tree.
(tree-in x tree) → *
No assumptions are made about the structure of the tree, so this search takes linear time. In practice, this function is only used as part of the logical definition of in (which is provided a more efficient implementation with mbe).
Function:
(defun tree-in (x tree) (declare (xargs :guard (binary-tree-p tree))) (declare (xargs :type-prescription (booleanp (tree-in x tree)))) (let ((__function__ 'tree-in)) (declare (ignorable __function__)) (and (not (tree-emptyp tree)) (or (equal x (tree-head tree)) (tree-in x (tree-left tree)) (tree-in x (tree-right tree))))))