Question
PROLOG multiple choice questions Please answer with full explanations 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).
PROLOG multiple choice questions
Please answer with full explanations
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
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. ==, \==
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).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started