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