我试图在 prolog 中编写二叉树,但出现以下错误:
Syntax error: Operator expected
在第一次调用 addChildren 时出现错误:
addChildren(node(Left, Right, Cand, [(Name, Profit, Weight)|T])):-
getTotalWeight(Cand, 0, Total),
%if total weight is less than 20
((Total + Weight) < 20 -> %then
New = [Cand | (Name, Profit, Weight)],
addChildren(Left(_,_, New, T)), %error here
addChildren(Right(_,_, Cand, T))
; %else
%end).
我正在使用以下节点:
node(node, node, [], []).
任何和所有的帮助表示赞赏。