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