John Dorian
John Dorian

Reputation: 51

How can I create a rule that takes one argument by referring to a rule that takes two arguments? (Beginner)

I want to create the following rule:

rule2(X) :-
  is "true" if rule1(X,Y) is false.

So rule2 will output a "true" for X, if rule1 outputs a "false" for X and any value Y


I hope this makes sense. I'm a beginner at prolog. It's been fun but I've been stuck on this issue for hours! Thanks.

Upvotes: 1

Views: 78

Answers (1)

gusbro
gusbro

Reputation: 22585

I'd suggest to use a logical not, \+/1 in favour of a !, fail approach:

rule2(X):- \+ (rule1(X,_)).

Upvotes: 1

Related Questions