Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROLOG 10. Write a prolog program for member/2 where member(X, Y) checks whether X is an element of a list Y. A. member(X,[X]). member(X,[Y|R]) :-

PROLOG

10. Write a prolog program for member/2 where member(X, Y) checks whether X is an element of a list Y.

A. member(X,[X]). member(X,[Y|R]) :- member(X,R).

B. member(X,X). member(X,[Y|R]) :- member(X,R).

C. member(X,[_]). member(X,[Y|R]) :- member(Y,R).

D. member(X,[X|R]). member(X,[Y|R]) :- member(X,[R]).

E. member(X,[X|R]). member(X,[Y|R]) :- member(X,R).

16. Using append/3, what would be the definition for prefix of a list?

A. prefix(P,L) :- append(P,_,L).

B. prefix(P,L) :- append(P,S,L).

C. prefix(P,L) :- member(P,S), append(P,S,L).

D. prefix(P,_) :- append(P,S,_).

E. prefix(L,P) :- append(P,_,L).

17. Using append/3, what would be the definition for suffix of a list?

A. suffix(S,L) :- prefix(P,L), append(S,P,L).

B. suffix(S,_) :- append(_,_,L).

C. suffix(P,S) :- append(P,S,_).

D. suffix(S,L) :- append(_,S,L).

E. suffix(P,S) :- append(P,S,_).

18. What is the following mystery/2 about? mystery([],[]). mystery([X|Y],Z) :- mystery(Y,W), takeout(X,Z,W). takeout(X,[X|R],R). takeout(X,[F|R],[F|S]) :- takeout(X,R,S).

A. append

B. prefix

C. permutation

D. reverse

E. suffix

F. member

G. sort

19. Consider the following query. It will have ___ answer(s). ?- member(X,[1,2,3,4]), Y = X*X, Y<10.

A. 0

B. 1

C. 2

D. 3

E. 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

7. Understand the challenges of multilingualism.

Answered: 1 week ago