File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -27,23 +27,21 @@ makeCacheMatrix <- function(dataMatrix = matrix()) {
27
27
# # within a wrapper list created by the makeCacheMatrix function.
28
28
29
29
cacheSolve <- function (matrixWrapper , ... ) {
30
-
31
30
# Retrieve the inverse stored in the wrapper object
32
31
inverse = matrixWrapper $ getInverse()
33
32
34
33
if (! is.null(inverse )) {
35
34
# Return the pre-calculated inverse
36
35
message(" getting cached data" )
37
- return (inverse )
36
+ } else {
37
+ # No inverse was found, so calculate it
38
+ message(" calculating data" )
39
+ dataMatrix = matrixWrapper $ get()
40
+ inverse = solve(dataMatrix )
41
+
42
+ # Store the caluclated inverse for future use
43
+ matrixWrapper $ setInverse(inverse )
38
44
}
39
45
40
- # No inverse was found, so calculate it
41
- message(" calculating data" )
42
- dataMatrix = matrixWrapper $ get()
43
- inverse = solve(dataMatrix )
44
-
45
- # Store the caluclated inverse for future use
46
- matrixWrapper $ setInverse(inverse )
47
-
48
46
inverse
49
47
}
You can’t perform that action at this time.
0 commit comments