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 3908dddCopy full SHA for 3908ddd
cachematrix.R
@@ -4,12 +4,31 @@
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
+ setmean <- function(mean) m <<- mean
14
+ getmean <- function() m
15
+ list(set = set, get = get,
16
+ setmean = setmean,
17
+ getmean = getmean)
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'
25
+ m <- x$getmean()
26
+ if(!is.null(m)) {
27
+ message("getting cached data")
28
+ return(m)
29
30
+ data <- x$get()
31
+ m <- solve(data, ...)
32
+ x$setmean(m)
33
+ m
34
0 commit comments