Here n is 3 and smaller than any of the numbers in the second input. By cons ing -1 onto this last list, we get the desired answer. Here is how we generalize from these examples. The problem requires a further case distinction. From here, we just need to put the proper answer expressions into the two cond -clauses.
Figure contains the complete definitions of insert and sort .
Develop a program that sorts lists of mail messages by date. Also develop a program that sorts lists of mail messages by name. It determines whether some number occurs in a list of numbers. The function may have to traverse the entire list to find out that the number of interest isn't contained in the list. Develop the function search-sorted , which determines whether a number occurs in a sorted list of numbers.