Skip to content

Commit 63d6df1

Browse files
committed
seems to work
1 parent 7f657dd commit 63d6df1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

cachematrix.R

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
## Put comments here that give an overall description of what your
1+
## Put comments here that give an overall description of what your
22
## functions do
33

44
## Write a short comment describing this function
55

66
makeCacheMatrix <- function(x = matrix()) {
7-
7+
m <- NULL
8+
set <- function(y) {
9+
x <<- y
10+
m <<- NULL
11+
}
12+
get <- function() x
13+
setinverse <- function(inverse) m <<- inverse
14+
getinverse <- function() m
15+
list(set = set, get = get, setinverse=setinverse, getinverse=getinverse)
816
}
917

1018

1119
## Write a short comment describing this function
1220

1321
cacheSolve <- function(x, ...) {
14-
## Return a matrix that is the inverse of 'x'
22+
m <- x$getinverse()
23+
if (!is.null(m)) {
24+
message('cached inverse')
25+
return(m)
26+
}
27+
m <- solve(x$get())
28+
x$setinverse(m)
29+
m
1530
}

0 commit comments

Comments
 (0)