For this problem, I'm assigned to implement a function that decides the output of a decision tree given the data. The logic: If it's a symbol, then that's the value to output otherwise, lookup the value of varname in the memory, and if it's less than or equal to the threshold, look for the value in the left-tree, and if it's greater than the threshold, look for the value in the right-tree
A decision tree is either: A symbol, e.g, 'versicolor or [ varname threshold left-tree right-tree ]
Here is what I've already done,
(defun decision (tree memory)
(if (not (equal (len tree) 0))
(if (not (equal (first tree) (first memory)))
(decision tree (rest memory))
(if (<= (second tree) (second memory))
(decision (third tree) memory)
(decision (fourth tree) memory)))
tree))
Here's one unit test:
(check-expect (decision *IRIS-DECISION-TREE*
(search-list-to-tree '((petal-length 2)
(petal-width 2)
(sepal-length 5))))
'setosa)
Here is the definition of the constant used
(defconst *IRIS-DECISION-TREE*
'(petal-length 245/100
setosa
(petal-width 175/100
(petal-length 495/100
(petal-width 165/100
versicolor
virginica)
(petal-width 155/100
virginica
(sepal-length 695/100
versicolor
virginica)))
(petal-length 485/100
(sepal-length 595/100
versicolor
virginica)
virginica))))
I keep getting errors when the function reaches the recursion call. It says "ACL2 Error in ( DEFUN DECISION ...): No :MEASURE was supplied with the definition of DECISION."
I tested every if statement to see if they work, and ran the logic of the code through my head multiple times and it seems like the only problem I might have could be an error in syntax but it all seems right.