Com S 342 --- Principles of Programming Languages LECTURE EXERCISES ON RECURSION ON FLAT LISTS 1. [zip] Write a procedure, zip, that takes two lists and produces a list of two element lists. For example, (zip '(3 4 2) '(5 9 7)) ==> ((3 5) (4 9) (2 7)) (zip '(4 2) '(9 7)) ==> ((4 9) (2 7)) (zip '() '(3 1 4 1 5 9)) ==> () (zip '(2 7 3 4) '()) ==> () 2. [xerox] Write a procedure, xerox, that takes a list of numbers and returns a list with those numbers duplicated. For example, (xerox '(3 9 2)) ==> (3 3 9 9 2 2) (xerox '(9 2)) ==> (9 9 2 2) (xerox '()) ==> () 3. [insert-before] Write a procedure, insert-before, that takes two elements, sought and to-insert, and a list of elements and which returns a list that is like the argument except that to-insert is placed in the output list just before the first occurrence of sought. For example, (insert-before 'x 'q '()) ==> () (insert-before 'x 'q '(x y z x)) ==> (q x y z x) (insert-before 'x 'q '(a x y z)) ==> (a q x y z) 4. [insert-before-all] Write a procedure, insert-before, that takes two elements, sought and to-insert, and a list of elements and which returns a list that is like the argument except that to-insert is placed in the output list just before the first occurrence of sought. For example, (insert-before-all 'x 'q '()) ==> () (insert-before-all 'x 'q '(x y z x)) ==> (q x y z q x) (insert-before-all 'x 'q '(a x y z x)) ==> '(a q x y z q x)