我正在尝试在ML中创建一个函数,该函数在二叉树中搜索值并返回true或false。任何人都可以帮我修复我的语法功能,以便它的工作原理?这就是我所拥有的:
datatype either = ImAString of string | ImAnInt of int;
datatype eitherTree = LEAF of either | NODE of eitherTree*either*eitherTree;
fun eitherSearch(LEAF(ImAnInt x), search_value) = (x=search_value)
| eitherSearch(LEAF(ImAString x), search_value) = false
| eitherSearch(NODE(left, ImAString node_value, right), search_value) = false
| eitherSearch(NODE(left, ImAnInt node_value, right), search_value) =
if (search_value > node_value)
then eitherSearch(right, search_value)
else eitherSearch(left, search_value);