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
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.
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.
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.
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.
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!
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