0
我试着写在序言二叉树,但得到以下错误: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, [], []).
任何和所有帮助表示赞赏。
和函数定义'addChildren(节点(左,右,C和[(名称,利润,重量)| T])): - ',太? – rhalliwell1 2012-04-29 13:16:08
@ rhalliwell1:正如我所解释的,这是一个语法错误。 – 2012-04-29 13:20:02
非常感谢:) – rhalliwell1 2012-04-29 13:22:44