Implementation of makeVector and cachemean functions