Com S 342 --- Principles of Programming Languages DISCUSSION SECTION PRACTICE WITH RECURSION ON FLAT LISTS 0. [list-copy] Write a procedure, list-copy : (forall (T) (-> ((list-of T)) (list-of T))) that takes a list, lst, and returns a new list that is just like lst. However, do not just return lst, but instead reconstruct a new list that is like lst and shares all it's top-level elements. For example: (list-copy '(a good egg is fried)) ==> (a good egg is fried) (list-copy '(1 1 1 0 1 1 2 1 2)) ==> (1 1 1 0 1 1 2 1 2) (list-copy '(a b c d)) ==> (a b c d) (list-copy '(b c d)) ==> (b c d) (list-copy '()) ==> () 1. [squares] Write a procedure, squares : (-> ((list-of number)) (list-of number)) that takes a list of numbers, lon, and returns a list of all the squares in lon, in order. For example: (squares '(1 2 3 4)) ==> (1 4 9 16) (squares '(2 3 4)) ==> (4 9 16) (squares '(3 4)) ==> (9 16) (squares '(4)) ==> (16) (squares '()) ==> () (squares '(12 12)) ==> (144 144) 2. [product] Write a procedure, product : (-> ((list-of number)) number) that takes a list of numbers, lon, and returns the product of all the numbers in lon. For example: (product '(1 2 3 4)) ==> 24 (product '(2 3 4)) ==> 24 (product '(3 4)) ==> 12 (product '(4)) ==> 4 (product '()) ==> 1 3. [some-even?] Write a procedure, some-even? : (-> ((list-of number)) boolean) that takes a list of numbers, lon, and returns true just when some number in lon is even. (Hint: Scheme has a predicate even? that tests to see if a number is even.) For example: (some-even? '(1 2 3 4)) ==> #t (some-even? '(2 3 4)) ==> #t (some-even? '(3 3 5 7 1)) ==> #f (some-even? '(10)) ==> #t (some-even? '()) ==> #f 4. [delete-even] Write a procedure, delete-even : (-> ((list-of number)) (list-of number)) that takes a list of numbers, lon, and returns a list that is just like lon except that it does not have the even elements of lon. For example: (delete-even '(1 2 3 4)) ==> (1 3) (delete-even '(2 3 4)) ==> (3) (delete-even '()) ==> () (delete-even '(12 6 5 20 12 6 3 10 1 342 541 641 8)) ==> (5 3 1 541 641) 5. [passing] Write a procedure, passing: (-> ((list-of (pair-of symbol number))) (list-of symbol)) that takes a list of pairs of symbols and numbers, and returns a list of the symbols for which the cdr of the pair contains a number that is strictly greater than 50. For example: (passing '((fred . 51) (mary . 80) (joe . 24) (frank . 50))) ==> (fred mary) (passing '((mary . 80) (joe . 24) (frank . 50))) ==> (mary) (passing '((joe . 24) (frank . 50))) ==> () (passing '()) ==> ()