P1: rev([],[]). rev([X|L],M) :- rev(L,K), append(K,[X],M). /* append is the builtin for lists concatenation */and
P2: rev(L,M) :- aux(L,M,[]). aux([],Acc,Acc). aux([X|L],M,Acc) :- aux(L,M,[X|Acc]).In what sense is the second program preferable to the fist? (only one answer, please)
p(leaf(X),1). p(node(T1,X,T2),N) :- p(T1,N1), p(T2,N2), N is N1 + N2.Consider now the query ?-p(t,N). where t is a term representing a certain tree. What is the result returned by it? (only one answer, please)
nat(0). nat(N) :- nat(M), N is M+1.Consider now the query ?- nat(N). What is the result returned by this query? (only one answer, please)