Apply a function against an accumulator and each element in an array and return the accumulated result.