Skip to content

Commit 5bd2f30

Browse files
committed
Modified Version with better comments
1 parent a314688 commit 5bd2f30

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cachematrix.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
## Write a short comment describing this function
2-
3-
makeCacheMatrix <- function(x = matrix()) {
1+
# The first function, makeMatrix creates a special "matrix", which is really a list containing a function to
2+
# set the value of the matrix
3+
# get the value of the matrix
4+
# set the value of the inverse of the matrix
5+
# get the value of the inverse of the matrix
6+
makeMatrix <- function(x = matrix()) {
47
m <- NULL
58
set <- function(y = matrix()) {
69
x <<- y
@@ -15,7 +18,7 @@ makeCacheMatrix <- function(x = matrix()) {
1518
}
1619

1720

18-
## Write a short comment describing this function
21+
# The following function calculates the inverse matrix of the special "matrix" created with the above function. However, it first checks to see if the inverse matrix has already been calculated. If so, it gets the inverse matrix from the cache and skips the computation. Otherwise, it calculates the inverse of the matrix and sets the value of the inverse_value in the cache via the setinverse function.
1922

2023
cacheSolve <- function(x, ...) {
2124
## Return a matrix that is the inverse of 'x'

0 commit comments

Comments
 (0)