COSC 341/342 HW 1012 FALL 2017 Haskell Exercises Distributed 10/12/2017 Due 10/19/2017 All code should be place in a single file. You will write a function for each of the problems below. Use list comprehension and pattern matching when possible. You should not use a Haskell function that immediately solves the problem. All functions should be given type declarations. For function names, you should use the names I have supplied in the following problems. (1) Given a list, return the tail of the list (note: do not use Haskell's tail) tail' [2, 3, 4] returns [3, 4] (2) Given a list of numbers, return product of the elements in the list (do not use Haskell's product) product' [2, 3, 4] returns 24 (3) Given two tuples (x1, y1) and (x2, y2), return the city block distance between them: distance = abs (x1 - x2) + abs (y1 - y2) -- abs is the mathematical absolute value cityBlock (1, 3) (4, 4) returns 4 (4) Given two tuples (x1 y1) and (x2, y2), that are each (Number, Number), return the distance between the two points: distance = sqrt ( (x1 - x2) ^ 2 + (y1 - y2) ^2 ) You can use Haskell's sqrt euclid (1, 1) (2, 2) returns 1.414213, approximately (5) Given two lists of numbers, return a list that is the sum of corresponding elements. If the lists are different lengths, stop the summing at the end of the shorter list. sum'' [] [1, 2, 3] returns [] sum'' [1, 2, 3] [4, 5, 6] returns [5, 7, 9] (6) Given two lists, they can be of any type, return the zipped list. Do not use Haskell's zip. zip' [] [1, 2, 3] returns [] zip' ['a', 'b'] [1, 2, 3] returns [('a', 1), ('b', 2) ] (7) Given two lists, the first has a list of values of any type, the second has a list of Bool values. Return the list containing only values in the first list where the corresponding value in the second list is True. pickIt [1, 2, 3] [True, False, True] returns [1, 3] pickIt ['a', 'b', 'c'] [False, False, True] returns ['c'] (8) Given a list of 2-tuples, the first element of each tuple is a String, the second element of each tuple is a Bool. The function pack will return the list of tuples that contains only the tuples that have the Bool value set to True. That is, the Bool value of each tuple can be thought of as a 'delete' bit. Example: pack [ ("a", True), ("b", False), ("c", False), ("d", True) ] returns [ ("a", True), ("d", True) ] (9) Implement ackermann's function. See: https://en.wikipedia.org/wiki/Ackermann_function Turn in: - Demo and walk-thru of at least two (instructor's choice) - hard copy of source code - screen shot showing each function's execution on all legal inputs.