The number of elements in a tree.
(tree-nodes-count tree) → *
Function:
(defun tree-nodes-count (tree) (declare (xargs :guard (binary-tree-p tree))) (declare (xargs :type-prescription (natp (tree-nodes-count tree)))) (let ((__function__ 'tree-nodes-count)) (declare (ignorable __function__)) (mbe :logic (if (tree-emptyp tree) 0 (+ 1 (tree-nodes-count (tree-left tree)) (tree-nodes-count (tree-right tree)))) :exec (fast-tree-nodes-count (list tree) 0))))