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