Haskell Mini-project #3 Distributed: 3/24/2015 Due: 3/31/2015 ---------------------------------------------------------------------------- Implement the following in Haskell (1) prefix takes 2 parameters and returns a list - a binary function that takes numbers and returns a number - a list of numbers The resulting list is formed by computed the successive function and accumulating as you go. The first (0 index element) value is computed as f (list !! 0) (list !! 0) For example prefix (+) [2, 4, 1, 1] returns [2, 6, 7, 8] prefix (+) [0, 2, -3, 4, -5] returns [0, 2, -1, 3, -2] prefix max [2, 3, 1, 1] returns [2, 3, 3, 3] (2) reduce takes as input -- a binary function that takes numbers and returns a number -- a single value (a number) -- a list of values (numbers) the result is the accumulated value over the single value and the values in the list. For example reduce (max) 3 [ 4, 2, 5, 1] returns 5 reduce (+) 3 [ 4, 2, 5, 1] returns 15 (3) scatter takes as input two parameters -- an integer >= 0 -- a list of values. The values can be any type returns a list of tuples. Each tuple is a pair. The first element is an integer starting at 0, then going up to n-1 where n is the value of first input parameter. The second element is an element from the list of values (second parameters), assigned to the tuples in round-robin fashion. For example. scatter 3 [1, 2, 3, 4, 5, 6, 7] returns [ (0, [1, 4, 7] ), (1, [2, 5] ), (2, [3, 6] ) ] scatter 5 ["ab", "2", "def", "4"] returns [ (0, ["abc"] ), (1, ["2"]), (2, ["def"]), (3, ["4"]), (4, []) ] (4) gather. gather performs the inverse of scatter. Take a list of tuples, the first element of the tuples is an integer. The tuples are sorted on the first element. The second element of each tuple is a list of values. Return the tuple ( Int, [Int] ), where the first value is the number of tuples in the input parameter, the second value is the concatenated list of the values from the second value of the tuples. Example: gather [ (0, [True, True] ), (1, [True, False] ), (2, [False, True]) ] returns (3, [True, True, False, True, False, True] ) gather [ (0, [1, 4, 7] ), (1, [2, 5] ), (2, [3, 6] ) ] returns ( 3 [1, 2, 3, 4, 5, 6, 7] ) ----------------------------------------------------------------------------- Turn in: Source code Run on above examples Grade based on: Meets specs Elegance Readability (documentation)