[英]Syntax error: Operator expected in prolog code
I'm new to prolog .. i tried this code but got error and don't know why ?!我是 prolog 的新手 .. 我试过这段代码但出错了,不知道为什么?!
de(F,L,R):-
R=[F|L].
is that because rule must have a recursion ?那是因为规则必须有递归吗? the error is
错误是
ERROR: Syntax error: Operator expected
In your comment , you specify what you did wrong: 在您的评论中,您指定您做错了什么:
i tested it as
de[a,[a,1,2,3],Z].
我将其测试为
de[a,[a,1,2,3],Z].
When you call a predicate, you use parenthesis ( (…)
), square brackets ( […]
) are used to construct lists.调用谓词时,使用括号 (
(…)
),方括号 ( […]
) 用于构造列表。 You thus should call the predicate with parenthesis:因此,您应该使用括号调用谓词:
?- def
(a,[a,1,2,3],Z
).
Z = [a, a, 1, 2, 3].
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.