Tizianoreica
Tizianoreica

Reputation: 2236

Check if two lists are different in prolog

diverso([X|L1],L2) :- nonp(X,L2), diverso(L1,L2).
nonp(X,[]).
nonp(X,[A|B]) :- X\=A, nonp(X,B).

this is my code, it doesn't work and I don't know why. Error is

Diverso/2 unknown predicate

My query is:

?-diverso([3,4],[1,2]).

Upvotes: 1

Views: 64

Answers (1)

Milo Wielondek
Milo Wielondek

Reputation: 4352

Adding the recursive base case for the diverso predicate solves the problem!

Upvotes: 1

Related Questions