introduce generic apply function for arrayops implementation