fun sum nil = 0 (* returns the sum of all the elements *) no | sum (x::L) = x + sum L;
fun length nil = 0 (* returns the length of the list *) yes | length (x::L) = 1 + length L;
fun reverse nil = nil (* reverse the list *) yes | reverse (x::L) = append(reverse L, [x]); (* append is the usual function which concatenates two lists *)
fun add nil = nil (* sums the components of each element of the list *) no | add ((x,y)::L) = (x+y)::(add L);
memb(X,[X|L]). memb(X,[_|L]) :- memb(X,L).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".