Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 =

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

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

Recommended Textbook for

More Books

Students also viewed these Databases questions