Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PROLOG Multiple Choice Questions 25. What is the result of the following Prolog

ID: 3734323 • Letter: P

Question

PROLOG Multiple Choice Questions

25. What is the result of the following Prolog statements?

?- assert(test(N,R) :- R is N*N).
?- maplist(test,[1,2,3,4],Rss).

A. Rss = [1, 2, 3, 4].

B. Rss = [1, 4, 9, 16].

C. Rss = [ ].

D. Rss = 16.

E. Rss = [[1, 2, 3, 4], [1, 4, 9, 16]].

F. false.

26. Consider the following bachelor Prolog program.
What would it be the "INCORRECT" result of the following query?

bachelor(P) :- male(P), not married(P).
male(henry).
male(tom).
married(tom).

A. ?- bachelor(henry).
yes
B. ?- bachelor(tom).
no

C. ?- bachelor(Who).
Who=henry

D. ?- married(X).
X=tom

E. ?- male(P).
no

27. 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).

28. As discussed in the class. Select the correct definition of sublist/2 (assuming append/3 provided).

A. sublist(X,L) :- suffix(X,L), prefix(S, X).

B. sublist(S,X) :- suffix(X,L), prefix(S, X).

C. sublist(S,L) :- suffix(X,L), prefix(S, X).

D. sublist(S,L) :- suffix(L,_), prefix(S, X).

E. sublist(S,X) :- suffix(X,L), prefix(S, X).

Explanation / Answer

25. option E , False

26. option E;

27. OPTION C

28.OPTION C ; sublists of a list L are the prefixes of suffixes of List L.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote