We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e4eed41 commit 1dc05a5Copy full SHA for 1dc05a5
1 file changed
cachematrix.R
@@ -1,15 +1,24 @@
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
+ m <- NULL
+ set <- function(y) {
+ x <<- y
+ m <<- NULL
+ }
+ get <- function() x
8
+ setsolve <- function(solve) m <<- solve
9
+ getsolve <- function() m
10
+ list(set = set, get = get,
11
+ setsolve = setsolve,
12
+ getsolve = getsolve)
13
}
14
cacheSolve <- function(x, ...) {
- ## Return a matrix that is the inverse of 'x'
15
-}
+ m <- x$getsolve()
16
+ if(!is.null(m)) {
17
+ message("getting cached data")
18
+ return(m)
19
20
+ data <- x$get()
21
+ m <- solve(data, ...)
22
+ x$setsolve(m)
23
+ m
24
+}
0 commit comments