File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Expand file tree Collapse file tree 1 file changed +26
-2
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
2
# # functions do
3
3
4
+ # # makeCacheMatrix creates a list of functions to control the cached values within the cacheSolve function.
5
+
6
+
4
7
# # Write a short comment describing this function
8
+ # # This function gets the matrix passed and store into the cache for future use, returning a list of functions to handle it.
5
9
6
10
makeCacheMatrix <- function (x = matrix ()) {
7
-
11
+ m <- NULL
12
+ set <- function (y ) {
13
+ x <<- y
14
+ m <<- NULL
15
+ }
16
+ get <- function () x
17
+ setsolve <- function (solve ) m <<- solve
18
+ getsolve <- function () m
19
+ list (set = set , get = get ,
20
+ setsolve = setsolve ,
21
+ getsolve = getsolve )
8
22
}
9
23
10
24
11
25
# # Write a short comment describing this function
26
+ # # This function verifies if the cache is set and uses it's value. If not, recalculate the matrix solve.
12
27
13
28
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
29
+ # # Return a matrix that is the inverse of 'x'
30
+ m <- x $ getsolve()
31
+ if (! is.null(m )) {
32
+ message(" getting cached data" )
33
+ return (m )
34
+ }
35
+ data <- x $ get()
36
+ m <- solve(data , ... )
37
+ x $ setsolve(m )
38
+ m
15
39
}
You can’t perform that action at this time.
0 commit comments