CrazyEngineers
  • Prolog System Predicates- Cut and Fail- a quiz

    Deepika Bansal

    Deepika Bansal

    @deepika-jf1ysv
    Updated: Oct 15, 2024
    Views: 1.0K
    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:
    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
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Deepika Bansal

    MemberApr 9, 2011

    No answer till now. Friends if you're having any doubt, please share with me, I'll help you to the best of my knowledge. We can start prolog from the very beginning if you want.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register