Search code examples
prologbacktrackingprolog-cut

Prolog, fail and do not backtrack


Is there any build-in predicate in SWI-Prolog that will always fail AND prevent machine from backtracking - it is stop the program from executing immediately (this is not what fail/0 does)? I could use cuts, but I don't like them.

Doing something like !, fail is not a problem for me, but in order to accomplish what I want, I would have to use cuts in more locations and this is what I don't like.


Solution

  • You could use exceptions. Based on your question - it should help. Refer link