File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 55
66makeCacheMatrix <- function (x = matrix ()) {
77
8+ i <- NULL
9+ set <- function (y ) {
10+ x <<- y
11+ <<- NULL
12+ }
13+ get <- function () x
14+ setinverse <- function (inverse ) i <<- inverse
15+ getinverse <- function () i
16+ list (set = set , get = get ,
17+ setinverse = setinverse ,
18+ getinverse = getinverse )
19+
820}
921
1022# # cacheSolve: This function computes the inverse of the special "matrix" returned by makeCacheMatrix above.
@@ -13,4 +25,15 @@ makeCacheMatrix <- function(x = matrix()) {
1325
1426cacheSolve <- function (x , ... ) {
1527 # # Return a matrix that is the inverse of 'x'
28+
29+ i <- x $ getInverse()
30+ if (! is.null(i )) {
31+ message(" getting cached data" )
32+ return (m )
33+ }
34+ data <- x $ get()
35+ i <- solve(data , ... )
36+ x $ setinverse(i )
37+ i
38+
1639}
You can’t perform that action at this time.
0 commit comments