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 7f657dd commit fd92549Copy full SHA for fd92549
cachematrix.R
@@ -4,6 +4,17 @@
4
## Write a short comment describing this function
5
6
makeCacheMatrix <- function(x = matrix()) {
7
+ m <- NULL
8
+ set <- function(y) {
9
+ x <<- y
10
+ m <<- NULL
11
+ }
12
+ get <- function() x
13
+ setinverse <- function(solve) m <<- solve
14
+ getinverse <- function() m
15
+ list(set = set, get = get,
16
+ setinverse = setinverse,
17
+ getinverse = getinverse)
18
19
}
20
@@ -12,4 +23,13 @@ makeCacheMatrix <- function(x = matrix()) {
23
24
cacheSolve <- function(x, ...) {
25
## Return a matrix that is the inverse of 'x'
26
+ m <- x$getinverse()
27
+ if(!is.null(m)) {
28
+ message("getting cached data")
29
+ return(m)
30
31
+ data <- x$get()
32
+ m <- solve(data, ...)
33
+ x$setinverse(m)
34
+ m
35
0 commit comments