File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change 1
- # # Put comments here that give an overall description of what your
2
- # # functions do
3
-
4
- # # Write a short comment describing this function
5
-
6
- makeCacheMatrix <- function (x = matrix ()) {
7
-
1
+ makeCacheMatrix <- function (x = matrix ()){
2
+ inv <- NULL
3
+ get <- function () x
4
+ inverse <- function () inv
5
+ set_inverse <- function (m ) inv <<- m
6
+ list (get = get , inverse = inverse , set_inverse = set_inverse )
8
7
}
9
8
10
-
11
- # # Write a short comment describing this function
12
-
13
- cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
9
+ cacheSolve <- function (x , ... ){
10
+ inv <- x $ inverse()
11
+ if (! is.null(inv )) return (inv )
12
+ dat <- x $ get()
13
+ inv <- solve(dat , ... )
14
+ x $ set_inverse(inv )
15
+ inv
15
16
}
You can’t perform that action at this time.
0 commit comments