John Jaques
John Jaques

Reputation: 560

Prolog Wildcard

I have the following clauses:

a(1).
a(a).
b(3).
b(a).
c(A,B) :- b(B),!,a(A).
c(X,_) :- a(X),b(X).

Query c(A,B) only returns two solutions: A = 1, B = 3 and A = a, B = 3. I traced c(A,B) and noticed that Prolog doesn't even try the second clause (c(X,_)). Why is that so?

Upvotes: 1

Views: 1005

Answers (1)

kaissun
kaissun

Reputation: 3086

The Prolog cut predicate, or '!', eliminates choices is a Prolog derivation tree.

Please check its role here

Upvotes: 3

Related Questions