目标是执行谓词noDupl/2
。确定逻辑程序
该谓词的第一个参数是要分析的列表,第二个参数是不重复的数字列表。
我不明白下面的代码,当我编译它,它给了一个错误消息contained
是不确定的过程,但作为提示,它是写,我们可以为预定义的谓语contained
和notContained
使用。我想我需要定义contained
和notContained
。
noDupl(XS, Res):-
help(XS, [],Res).
help([],_,[]).
help([X|XS],Seen,[X|Res]):-
notContained(X,XS),
notContained(X,Seen),
help(XS, [X|Seen], Res).
help([X|XS],Seen,Res):-
contained(X,Seen),
help(XS, Seen, Res).
help([X|XS],Seen,Res):-
contained(X,XS),
help(XS, [X|Seen], Res).
有人可以请解释我的问题。
@false。谢谢!为什么不使用[tag:dcg]和['if _ // 3'](http://stackoverflow.com/a/29366458/4609915)?它会*更简洁 - 但是什么是专名? – repeat