4

  • Given the following facts:
           likes(mary, pizza).
           likes(mary, curry).
           likes(john, beer).
           likes(john, pizza).
    
           is_liked(X) :- likes(_, X).
           
    what is the output of the following queries?
    1. ?- setof(X, is_liked(X), List1).
      Solution:
      X = _G187
      List1 = [beer, curry, pizza]
             

       
    2. ?- findall(X, likes(_, X), List2).
      Solution:
      X = _G187
      List2 = [pizza, curry, beer, pizza]