File tree 1 file changed +24
-9
lines changed
1 file changed +24
-9
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
3
-
4
- # # Write a short comment describing this function
1
+ # #Please include your own comment to explain your code (Required in Rubric)
5
2
6
3
makeCacheMatrix <- function (x = matrix ()) {
7
-
4
+ j <- NULL
5
+ set <- function (y ){
6
+ x <<- y
7
+ j <<- NULL
8
+ }
9
+ get <- function ()x
10
+ setInverse <- function (inverse ) j <<- inverse
11
+ getInverse <- function () j
12
+ list (set = set , get = get ,
13
+ setInverse = setInverse ,
14
+ getInverse = getInverse )
8
15
}
9
16
10
-
11
- # # Write a short comment describing this function
17
+ # #Please include your own comment to explain your code (Required in Rubric)
12
18
13
19
cacheSolve <- function (x , ... ) {
14
- # # Return a matrix that is the inverse of 'x'
15
- }
20
+ # # Return a matrix that is the inverse of 'x'
21
+ j <- x $ getInverse()
22
+ if (! is.null(j )){
23
+ message(" getting cached data" )
24
+ return (j )
25
+ }
26
+ mat <- x $ get()
27
+ j <- solve(mat ,... )
28
+ x $ setInverse(j )
29
+ j
30
+ }
You can’t perform that action at this time.
0 commit comments