Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the Prolog colon operator mean?

Tags:

prolog

I found another post that discussed the colon, but the expression doesn't look quite the same.
I see this X variable can be passed as an argument, curious what it does?

X = x:2

like image 905
Chaos Avatar asked Mar 05 '13 06:03

Chaos


People also ask

What does the semicolon mean in Prolog?

In Prolog, semicolon means "or," whereas a comma means "and." Since we defined two predicates, we can try using both of them in the same query.

What does symbol mean in Prolog?

symbol represents the cut . You can read more about cut here. Also, an example in prolog can be found here. Follow this answer to receive notifications.

What does \+ mean in Prolog?

Because of the problems of negation-as-failure, negation in Prolog is represented in modern Prolog interpreters using the symbol \+ , which is supposed to be a mnemonic for not provable with the \ standing for not and the + for provable.

How do you give or in Prolog?

Performing an "or" in Prolog can also be done with the "disjunct" operator or semi-colon: registered(X, Y) :- X = ct101; X = ct102; X = ct103.


1 Answers

Without modules, : is an infix function symbol. You can try this out by executing

?- x:2 =.. X.
X = [:, x, 2].

at the swi prompt.

Some explanation for the =.. operator: it is a relation where the left hand side is an arbitrary term "symbol(argument1, argument2,...)" and the right hand side is a list "[symbol, argument1, argument2, ...]".

hope it helps!

like image 103
lambda.xy.x Avatar answered Sep 16 '22 17:09

lambda.xy.x