Updated cachematrix.R

using similar logic provided in the example (Caching the Mean of a Vector)