We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b22d21 commit fac1c72Copy full SHA for fac1c72
cachematrix.R
@@ -5,11 +5,28 @@
5
6
makeCacheMatrix <- function(x = matrix()) {
7
8
+ m <- NULL
9
+ get <- function() x
10
+ setinverse <- function(inverse) m <<- inverse
11
+ getinverse <- function() m
12
+
13
+ list(get = get,
14
+ setinverse = setinverse,
15
+ getinverse = getinverse)
16
}
17
18
19
## Write a short comment describing this function
20
21
cacheSolve <- function(x, ...) {
22
## Return a matrix that is the inverse of 'x'
23
+ m <- x$getinverse()
24
+ if (!is.null(m)) {
25
+ message("Getting cached data")
26
+ return(m)
27
+ }
28
+ data <- x$get()
29
+ m <- solve(data)
30
+ x$setinverse(m)
31
+ m
32
0 commit comments