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

PROLOG 20. Consider the following mystery/3 predicate. mystery(X,[X|R],R). myste

ID: 3734322 • Letter: P

Question

PROLOG

20. Consider the following mystery/3 predicate.


            mystery(X,[X|R],R).
            mystery(X,[F|R],[F|S]) :- mystery(X,R,S).


What is the result L of the following query:
?- mystery(1,[1,2,3], L).

A. L=1

B. L=2

C. L=3

D. L=[2,3]

E. L=[1,1,2,3]

F. L=[1]

21. What is the result of the following query?
?- transpose([[1,2,3],[4,5,6],[7,8,9]], Ts).

A. Ts = [1, 4, 7].

B. Ts = [1, 4, 7], [2, 5, 8], [3, 6, 9].

C. Ts = [1, 4, 7, 2, 5, 8, 3, 6, 9].

D. Ts = [1, 2, 3, 4, 5, 6, 7, 8, 9].

E. Ts = [[1, 4, 7], [2, 5, 8], [3, 6, 9]].

F. Ts = [1, 2, 3].

22 Which of the following selections is correct?
This ____ is to add a new fact or rule (clause).

A. args/3

B. assert/1

C. atom/1

D. clause/2

E. call/1

F. findall/3

G. functor/3

H. ground/1

I. op/3

J. retract/1, retractall/1

K. var/1

L. =, =

M. ==, ==

23. What is the predicate ___ for the following query and its result?
          ?- ____(f(a,b),F,A).
          A = 2
          F = f

A. args/3

B. assert/1

C. atom/1

D. clause/2

E. call/1

F. findall/3

G. functor/3

H. ground/1

I. op/3

J. retract/1

K. var/1

L. =, =

M. ==, ==

24. What is the predicate ___ for the following query and its result?

?- ___(2,loves(richard, sarah), X).
X = sarah
         

A. arg/3

B. assert/1

C. atom/1

D. clause/2

E. call/1

F. findall/3

G. functor/3

H. ground/1

I. op/3

J. retract/1

K. var/1

L. =, =

M. ==, ==

Explanation / Answer

21. What is the result of the following query?
?- transpose([[1,2,3],[4,5,6],[7,8,9]], Ts).

A. Ts = [1, 4, 7].

B. Ts = [1, 4, 7], [2, 5, 8], [3, 6, 9].

C. Ts = [1, 4, 7, 2, 5, 8, 3, 6, 9].

D. Ts = [1, 2, 3, 4, 5, 6, 7, 8, 9].

E. Ts = [[1, 4, 7], [2, 5, 8], [3, 6, 9]].

F. Ts = [1, 2, 3].

Answer:

E. Ts = [[1, 4, 7], [2, 5, 8], [3, 6, 9]].

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote