COSC 341/342 FALL 2015 Haskell mini project 3 Distributed 10/14/2015 Due 10/26/2015 All code should be place in a single file. You will write a function for each of the problems below. Use function definitions, list comprehension and pattern matching when possible. Consider using foldl, foldr, scanl, scanr. You should write any 'helper' functions you need or want. You may use any built-in Haskell functions. Handle any parameters that are empty lists or 0s in an intelligent manner. (1) count a -> [a] -> Int return the number of times a appears in the list count 2 [2, 3, 2, 1, 2, 5] -----> 3 count "abc" [ "aaa", "abc", "ABC", "bbbdefg"] ------> 1 (2) get_last [a] -> a return the final element in the list get_last [1, 2, 3, 5] ---> 5 (3) get_next_to_last [a] -> a return the penultimate element in the list get_next_to_last [1, 2, 3, 5] ---> 3 (4) pick_random [a] -> a return a randomly chosen element from the list pick_random [1, 2, 3, 4, 5] ---> 3 pick_random [1, 2, 3, 4, 5] ---> 1 (5) choose a -> [a] -> [a] From a list, output a list of n elements, each of which is randomly chosen. The items picked for output are chosen with replacement. The first argument is the number of items chosen (n), the second argument is the list of available values to pick. choose 3 [1, 2, 3, 4, 5] ---> [1, 4, 3] choose 3 [1, 2, 3, 4, 5] ---> [1, 5, 5] choose 3 [1, 2] ---> [2, 2, 2] choose 3 [1] ---> [1, 1, 1] (6) ackermann a -> a -> a Implement Ackermann's function. (Everyone should implement Ackermann's at some point) (https://en.wikipedia.org/wiki/Ackermann_function) Turn in: - hard copy of source code - screen shot showing each function's execution on all legal inputs. Grade based on: Meets specs Elegance Readability (documentation and naming)