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