148k views
0 votes
Complete the second clause of the following Prolog program for member/2 where member(X, Y) checks whether X is an element (a member) of a list Y. member(X,[X|R]). member(X,[Y|R]) :- ____________.A. member(X,R).

B. member(X,Y).
C. member(_,R).
D. member(Y,R).
E. member(X,Y).

User Jim Geurts
by
5.8k points

1 Answer

1 vote

Answer:

The answer is "Option A"

Step-by-step explanation:

In the given program code, two-member "X, Y" is used, in which X is an element of the list and Y is the list. In this another variable R declares, that store a number for the match, in this question choice "A" is correct because it uses an element and variable "R" for check and wrong choices can be described as follows:

  • In option B, in this two-parameter is used, in which one is an element and one is the list, that's why it is incorrect.
  • In option C, It is wrong because there is no underscore variable.
  • Option D and Option E both were wrong because in this list is passed as the parameter.
User Nowshad Syed
by
4.7k points