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 5
5
6
6
makeCacheMatrix <- function (x = matrix ()) {
7
7
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
+
8
20
}
9
21
10
22
# # cacheSolve: This function computes the inverse of the special "matrix" returned by makeCacheMatrix above.
@@ -13,4 +25,15 @@ makeCacheMatrix <- function(x = matrix()) {
13
25
14
26
cacheSolve <- function (x , ... ) {
15
27
# # 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
+
16
39
}
You can’t perform that action at this time.
0 commit comments