I have an exam in Prolog today and am revising for it using old questions.
Would answer c be the incorrect answer? Can anyone please explain this to me? It would be very helpful. Thank you,
Consider the following predicate:
swap([], []).
swap([X1, X2 | L], [X2, X1 | S]) :- swap(L, S).
Which of the following query and answer pairs is incorrect:
(a) ?- swap([a,b,c,d], S).
S = [b, a, d, c].
(b) ?- swap([a,b,d], H).
false.
(c) ?- swap([a,a,b,b], S).
S = [b, b, a, a].
(d) ?- swap([], S).
S = [].