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 6ad1281Copy full SHA for 6ad1281
cachematrix.R
@@ -3,13 +3,22 @@
3
4
## Write a short comment describing this function
5
6
-makeCacheMatrix <- function(x = matrix()) {
7
-
+makeCacheMatrix <- function() {
+mat <- NULL
8
+inv_cache <- NULL
9
+setMatrix <-function(x){
10
+mat <<-x
11
+inv_cache<<- NULL
12
}
-## Write a short comment describing this function
13
-cacheSolve <- function(x, ...) {
14
- ## Return a matrix that is the inverse of 'x'
+getInverse <- function() {
+if (is.null(inv_cache)){
15
+inv_cache <<-solve(mat)
16
+}
17
+inv_cache
18
19
+list(setMatrix=setMatrix,getInverse = getInverse)
20
21
+cacheSolve <- function(x,...){
22
+inv_cache <-x$getInverse()
23
24
0 commit comments