cachematrix assignment for R programming class