Skip to content

Commit 6a7688e

Browse files
committed
Add some explanatory comments
1 parent bb048d7 commit 6a7688e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

cachematrix.R

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
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+
#
2+
# Functions `makeCacheMatrix` and `cacheSolve`.
3+
#
4+
# These are so close to the examples `makeVector` and `cachemean` that it almost
5+
# feels like cheating...
6+
7+
# The `makeCacheMatrix` function creates a list of closures, which access a
8+
# stored matrix and an alternative representation of the matrix.
9+
# Returns a list of functions which encapsulate the matrix object:
10+
# * getter & setter for the matrix
11+
# * getter & setter for the alternative representation
512

613
makeCacheMatrix <- function(x = matrix()) {
714
invmatrix <- NULL
@@ -19,7 +26,9 @@ makeCacheMatrix <- function(x = matrix()) {
1926
}
2027

2128

22-
## Write a short comment describing this function
29+
# The `cacheSolve` function returns the cached inverse of the matrix inside the
30+
# scope accessed by the functions in `x`, solving and caching the inverse if it
31+
# does not already exist.
2332

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

0 commit comments

Comments
 (0)