vendredi 18 mars 2016

how to do proper flow control in Prolog without using the non-declarative if-then-else syntax

I would like to check for an arbitrary fact and do something if it is in the knowledge base and something else if it not, but without the ( I -> T ; E) syntax

i have some facts in my knowledge base

unexplored(1,1).
unexplored(2,1).
safe(1,1).

given an incomplete rule

foo:- safe(A,B),
% do something if unexplored(A,B) is in the knowledge base
% do something else if unexplored(A,B) is not in the knowledge base

what is the correct way to handle this without doing it like this

foo:- safe(A,B),
unexplored(A,B)->something ; something_else.

Aucun commentaire:

Enregistrer un commentaire