Implement a generic function called
reduce
which will take a function as the first argument, a list as a second argument, and an initial value as the third argument. The reduce
function should return a single value which is obtained after applying it to all the elements of the list.