File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 4
4
# # Write a short comment describing this function
5
5
6
6
makeCacheMatrix <- function (x = matrix ()) {
7
+ m <- NULL
8
+ set <- function (y ) {
9
+ x <<- y
10
+ m <<- NULL
11
+ }
12
+ get <- function () x
13
+ setinverse <- function (inv ) m <<- inv
14
+ getinverse <- function () m
15
+ list (set = set , get = get ,
16
+ setinverse = setinverse ,
17
+ getinverse = getinverse )
7
18
8
19
}
9
20
10
21
11
22
# # Write a short comment describing this function
12
23
13
24
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
25
+ # # Return a matrix that is the inverse of 'x'
26
+ m <- x $ getinverse()
27
+ if (! is.null(m )) {
28
+ message(" getting cached data" )
29
+ return (m )
30
+ }
31
+ data <- x $ get()
32
+ m <- solve(data , ... )
33
+ x $ setinverse(m )
34
+ m
15
35
}
You can’t perform that action at this time.
0 commit comments