0

In prolog, is it possible to force a fail? Something like:

check(F,A,[1,2,3]) :- FAIL.
check(F,A,_) : greater_than(F,A).

This may be a bad example, but something along the lines of this.

So if it does a pattern match on F,A,[1,2,3], then we just stop the who unifying process, and return a false.

omega
  • 40,311
  • 81
  • 251
  • 474

1 Answers1

1

Prolog has a built-in fail/0 predicate, which always fails. You need a cut ! in front of it in order to prevent further matching of the same check/3 rule:

check(F,A,[1,2,3]) :- !, fail.
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523