Spring 2002, CSE 428: Quiz 10.3 - 23 April 2002


Please write your Name, Student ID, and Section at the top of the page. By default, this quiz will be return in section 1 (afternoon section). If you want to get it back in the morning section, please write "return in section 2" at the top.
  1. [Points 2] Consider the following program computing the reverse of a list with the method of the accumulator:
       rev(L,M) :- aux(L,M,[]).
       aux([],Acc,Acc).       
       aux([X|L],M,Acc) :- aux(L,M,[X|Acc]).
    
    What is the result produced by the query ?- aux([1,2],M,[3,4]). ? (only one answer, please).

  2. [Points 2] Consider the Prolog query ?- Y = 2+3, X is 1+Y. What is the result returned by it? (only one answer, please)

  3. [Points 2] Is there a unifier for the two Prolog terms f(f(X,Y),3) and f(Y,X)?
  4. [Points 4] Consider the usual definition of the append predicate:
       append([],L,L).
       append([X|L],K,[X|M]) :- append(L,K,M).
    
    For each of the following queries, please indicate all the answers that are returned (assuming that we interactively keep asking for more answers). If no answers are returned, write "no". If the query generates an error, write "error".