implement apply(): apply any function to each object in vector