如何在 SWI-Prolog 中使用列表构造函数 (./2) [英] How to use list constructors (./2) in SWI-Prolog
本文介绍了如何在 SWI-Prolog 中使用列表构造函数 (./2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 SWI-Prolog 中使用列表构造函数,但收到dict"预期错误.
I am trying to use list constructor in SWI-Prolog, but am getting 'dict' expected error.
例如,
.(a, []) == [a].
ERROR: Type error: `dict' expected, found `a' (an atom)
ERROR: In:
ERROR: [11] throw(error(type_error(dict,a),_14808))
ERROR: [10] '$type_error'(dict,a) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:3369
ERROR: [9] '$dicts':'.'(a,[],_14874) at /Applications/SWI-Prolog.app/Contents/swipl/boot/dicts.pl:46
ERROR: [8] '<meta-call>'(user:(...,...)) <foreign>
ERROR: [7] <user>
Exception: (9) '.'(a, [], _14200) ?
谁能帮我配置这个功能?
Could anyone help me configure this functionality?
推荐答案
SWI-Prolog 7.x 使用不同的列表构造函数 '[|]'/2
,而不是传统的 >./2
Prolog 构造函数:
SWI-Prolog 7.x uses a different list constructor, '[|]'/2
, instead of the traditional ./2
Prolog constructor:
?- '[|]'(1,[]) == [1].
true.
更改的动机是将 ./2
释放用于其他用途,特别是在 dict 术语中,正如您在查询中获得的错误消息所暗示的那样.
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.
这篇关于如何在 SWI-Prolog 中使用列表构造函数 (./2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文