Revised cachematrix.R pseudocode with actual code