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

后端 未结 2 544
执念已碎
执念已碎 2020-12-20 23:17

I am trying to use list constructor in SWI-Prolog, but am getting \'dict\' expected error.

For example,

.(a, []) == [a].

ERROR: Type error: `dict\         


        
2条回答
  •  醉话见心
    2020-12-21 00:11

    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.

提交回复
热议问题