Solved Problem 5, and managed to work in a use of currying to keep funs abstract.