# MCS-177, Intro. to Computer Science I, Fall 2002  Review Problems for Chapter 7

1. Basic list manipulations
1. Write a procedure that will find the product of a list of numbers.
2. Write a procedure that will produce a list with n copies of a given element.
3. Write a procedure that will double every element in a list.If you double the list (1 2 3), you get the list (1 1 2 2 3 3).
2. Lists and iteration
Write a procedure that will find the largest element in a list.
3. Lists and time complexity
1. Write a procedure that will take two lists and append one to the other. The new list should be a list consisting of the elements of the first list followed by the elements of the second list.
2. What is the time complexity of your procedure, in terms of the sizes of the lists?
4. Lists and higher order programming
1. Write a procedure that takes a list of functions and a number and produces the list of the values of the functions when applied to the number.
2. Write a procedure called compose that will take a list of procedures and produces the procedure that is the composition of the procedures in the list. For example, ((compose (list square add-one)) 3) ==> 16
5. Lists and tree recursion
This is a challenging problem. An s-list is either a number, a symbol, or a list of s-lists. Thus, ((2) 3 ((4) a) () ) is an s-list. Write a procedure called flatten that will take an s-list and turn it into a list of just symbols and numbers. If we flatten the list above, we get the list (2 3 4 a).

MCS 177 homepage