Prolog System Predicates- Cut and Fail- a quiz
Hello friends. Today I was having my Prolog exams. There I had a very interesting question that I would like to share with you.
Ques: If there are N one argument facts for the predicate named 'test1' and M one argument facts for the predicate named 'test2'.
This would be like:
Ques: If there are N one argument facts for the predicate named 'test1' and M one argument facts for the predicate named 'test2'.
This would be like:
test1(1). test2(1). test1(2). test2(2). test1(3). test2(3). | | test1(n). test2(m).Now find the maximum number of possible answers all the values of z for the query 'z' as:
?-z.where the rule z in various cases is:
1. z:- test1(X), !, test2(X). 2. z:- test1(X), test2(X), !. 3. z:- !, test1(X), test2(X). 4. z:- test1(X), fail, test2(X). 5. z:- test1(X), !, test2(Y). 6. z:- test1(X), test2(Y), !. 7. z:- !, test1(X), test2(Y). 8. z:- test1(X), test2(Y), fail.Feel free to ask any question on this topic.😀
0