Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30a1180

Browse files
committed
solved
1 parent 7f657dd commit 30a1180

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

cachematrix.R

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1-
## Put comments here that give an overall description of what your
2-
## functions do
31

4-
## Write a short comment describing this function
2+
3+
## making matrix object with all required inner functions :)
54

65
makeCacheMatrix <- function(x = matrix()) {
6+
i <- NULL
7+
set <- function(y) {
8+
x <<- y
9+
i <<- NULL
10+
}
11+
get <- function() x
12+
getinvert <- function() {
13+
i
14+
}
15+
setinvert <- function(y) {
16+
i<<-y
17+
}
18+
list(set = set, get = get,
19+
getinvert = getinvert,
20+
setinvert = setinvert)
721

822
}
923

1024

11-
## Write a short comment describing this function
25+
## getting the invert value
1226

1327
cacheSolve <- function(x, ...) {
14-
## Return a matrix that is the inverse of 'x'
28+
i <- x$getinvert()
29+
if(!is.null(i)) {
30+
message("getting cached data")
31+
return(i)
32+
}
33+
data <- x$get()
34+
i <- solve(data, ...)
35+
x$setinvert(i)
36+
i
1537
}

0 commit comments

Comments
 (0)