|
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()) { |
| 1 | +makeCacheMatrix = function(squid = matrix()) { |
| 2 | + ## This function returns a "matrix" which is a list with the ability |
| 3 | + ## to cache the result of the inverse of the original matrix, "squid". |
| 4 | + ## The inverse must be calculated using the funcion "cacheSolve" on it. |
| 5 | + splat = NULL |
| 6 | + krakon = function(fresh){ |
| 7 | + squid <<- fresh |
| 8 | + splat <<- NULL |
| 9 | + } |
| 10 | + tentatek = function(){squid} |
| 11 | + splatroller = function(inkstrike) splat <<- inkstrike |
| 12 | + splattershot = function(){splat} |
7 | 13 |
|
| 14 | + list(set=krakon,tentatek=tentatek,splatroller=splatroller,splattershot=splattershot) |
8 | 15 | }
|
9 | 16 |
|
10 |
| - |
11 |
| -## Write a short comment describing this function |
12 |
| - |
13 |
| -cacheSolve <- function(x, ...) { |
14 |
| - ## Return a matrix that is the inverse of 'x' |
| 17 | +cacheSolve = function(inkling, ...) { |
| 18 | + ## Return a matrix that is the inverse of 'squid' |
| 19 | + ## Return the cached value if the matrix has not |
| 20 | + ## changed and it exists. Otherwise, calculate |
| 21 | + ## it and store it. |
| 22 | + splat = inkling$splattershot() #You are a kid |
| 23 | + if(!is.null(splat)){ |
| 24 | + message("Getting cached data") |
| 25 | + return(splat) |
| 26 | + }#Now you are a squid! |
| 27 | + squid = inkling$tentatek() |
| 28 | + splat = solve(squid, ...) |
| 29 | + inkling$splatroller(splat) |
| 30 | + splat |
15 | 31 | }
|
0 commit comments