More Exercises --------------- Exercise 1: Write a procedure that takes two lists of the same length as input, and returns a new list whose elements are lists that pair corresponding elements of the input lists. (pair-lists (list 1 2 3) (list 4 5 6)) ;Value: ((1 4) (2 5) (3 6)) (pair-lists (list) (list)) ;Value: () Exercise 2: Write a procedure to reverse a list. You may want to use the procedure append, which glues two lists together: (append (list 1 2 3) (list 4 5 6)) ;Value: (1 2 3 4 5 6) (reverse (list 1 2 3 4 5 6)) ;Value: (6 5 4 3 2 1) (reverse (list)) ;Value: () There are two ways to write reverse. One uses append, the other runs faster, doesn't use append, and is harder to see. Exercise 3: Write a procedure named make-adder, that when given a number, returns a procedure that adds that number to it's input. (define add-3 (make-adder 3)) (add-3 4) ;Value: 7 (add-3 5) ;Value: 8 add-3 ;Value: #[compound-procedure 8] ((make-adder 6) 6) ;Value: 12 Exercise 4: Write a procedure that takes a list of numbers and returns a list of their recipricals. You'll probably want to use map. (recips (list 1 2 3)) ;Value: (1. .5 .333333333) Exercise 5: Write a procedure that takes a list of numbers and returns a list of just the non-prime numbers. You'll probably want to use filter. (non-primes (list 2 3 4 5 6 7 8)) ;Value: (4 6 8) Exericse 6: Write a procedure called remove-duplicates that takes a list of numbers and returns a list with a unique instance of each number. You will want to use filter (delnum won't quite get you there). (remove-duplicates (list 1 2 3 1 2 3 4 5 5 7 2 2 2)) ;Value: (1 2 3 4 5 7)