fold the elements of this array using the given monoid and initial valueUsed to fold an array tail-recursively