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