Skip to content

Commit 604bdf2

Browse files
committed
Splatted some matrices
1 parent 140a0d7 commit 604bdf2

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

cachematrix.R

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
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}
713

14+
list(set=krakon,tentatek=tentatek,splatroller=splatroller,splattershot=splattershot)
815
}
916

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
1531
}

0 commit comments

Comments
 (0)