问题
I could not find explicitly what (:) stands for in prolog.
In interactive mode you can see the following evidence:
?- display(a:b).
:(a,b)
true.
?- display([a,b,c]).
.(a,.(b,.(c,[])))
true.
?- display(a:b:c:[]).
:(a,:(b,:(c,[])))
true.
?- a:b:REST = a:TAIL.
TAIL = b:REST.
For what purpose (:) is introduced? I could not find any details for it in www. Seems that it gives another syntactic way of talking about recursive structures as Lists.
We can say that it is Right-associative, what is its priority number?
:-op(??, xfy, :).
Is there a way to list all such kind of implicit functors?
listing(op). %of course this does not work
回答1:
That's the module qualifier, you can see its declaration with this:
?- current_op(X,Y,:).
X = 600,
Y = xfy.
Modules are an important extension to Prolog, particularly required for large programs, but miss from ISO standard. SWI-Prolog has (as usually) a pragmatic viewpoint on this, and implements an useful approach.
OT inspecting operators, you could find this snippet useful:
oplist :-
setof((A,C,B), current_op(A,B,C), L),
maplist(writeln, L).
来源:https://stackoverflow.com/questions/12759700/what-does-the-colon-exactly-stand-for-in-swi-prolog