File tree Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Original file line number Diff line number Diff line change 1
- # # Put comments here that give an overall description of what your
2
- # # functions do
1
+ # # TODO more comments
3
2
4
- # # Write a short comment describing this function
3
+ # # Sets the value of the matrix
4
+ # # Gets the value of the matrix
5
+ # # Sets the inverse
6
+ # # Gets the inverse
5
7
6
8
makeCacheMatrix <- function (x = matrix ()) {
7
-
9
+ i <- NULL
10
+ set <- function (y ) {
11
+ x <<- y
12
+ i <<- NULL
13
+ }
14
+ get <- function () x
15
+ setinverse <- function (inverse ) i <<- inverse
16
+ getinverse <- function () i
17
+ list (set = set , get = get ,
18
+ setinverse = setinverse ,
19
+ getinverse = getinverse )
8
20
}
9
21
10
22
11
- # # Write a short comment describing this function
23
+ # # TODO write more comments
12
24
13
25
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
26
+ # # Return a matrix that is the inverse of 'x'
27
+ i <- x $ getinverse()
28
+ if (! is.null(i )) {
29
+ message(" getting cached data" )
30
+ return (i )
31
+ }
32
+ data <- x $ get()
33
+ i <- solve(data , ... )
34
+ x $ setinverse(i )
35
+ i
15
36
}
You can’t perform that action at this time.
0 commit comments