I am trying to use list constructor in SWI-Prolog, but am getting 'dict' expected error.
For example,
.(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 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].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With