Skip to content

Commit e4ff9fa

Browse files
author
Sean Hill
committed
Add function to build matrix with cacheable solve (inverse)
1 parent 8f9a5f1 commit e4ff9fa

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

cachematrix.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@
22
## Use the makeCacheMatrix to return a cacheable matrix and then use
33
## cacheSolve to compute the inverse and cache it or return the cached inverse
44

5-
## Write a short comment describing this function
5+
## This function takes a matrix and returns a list of functions for caching its inverse
66

77
makeCacheMatrix <- function(x = matrix()) {
8-
8+
s <- NULL
9+
10+
set <- function(y) {
11+
x <<- y
12+
s <<- NULL
13+
}
14+
15+
get <- function() x
16+
17+
set_solve <- function(solve) s <<- solve
18+
get_solve <- function() s
19+
20+
list(set = set, get = get, set_solve = set_solve, get_solve = get_solve)
921
}
1022

1123

0 commit comments

Comments
 (0)