
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

A recursive function has two parts, the basis and the inductive step.
The following recursive function (which is intended to reverse a list and which is almost identical to the correct version of naive reverse that we discussed in class on Thursday) breaks one of these two rules. Which one? In which way?
fun reverse(L) = if L = nil then nil else reverse(L) @ [hd(L)];
Answer: The second (because the recursive call does not have a smaller argument)