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