How to use list constructors (./2) in SWI-Prolog

这一生的挚爱 提交于 2019-11-29 14:40:29

SWI-Prolog 7.x uses a different list constructor, '[|]'/2, instead of the traditional ./2 Prolog constructor:

?- '[|]'(1,[]) == [1].
true.

The change was motivated to free ./2 for other uses, notably in dict terms, as hinted in the error message you got for your query.

Better to use | in conventional notation,

?- X = '[|]'(1,[0]).
X = [1, 0].

can be write like this

?- X = [1|[0]].
X = [1, 0].
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!