Skip to content

Commit 61a4dfb

Browse files
committed
added comments
1 parent 47378ee commit 61a4dfb

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

cachematrix.R

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
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-
1+
# makeCacheMatrix function will store the matrix (original) data and the inverse matrix
2+
# and returns those data when requested
63
makeCacheMatrix <- function(x = matrix()) {
74
s <- NULL
85
set <- function(y) {
@@ -17,11 +14,11 @@ makeCacheMatrix <- function(x = matrix()) {
1714
getsolve = getsolve)
1815
}
1916

20-
21-
## Write a short comment describing this function
22-
23-
cacheSolve <- function(x, ...) {
24-
## Return a matrix that is the inverse of 'x'
17+
# cacheSolve function work togheter with makeCacheMatrix,
18+
# this will check first
19+
# if inverse matrix was already solved and return
20+
# else solve and store it on "cache" for posterior use
21+
cacheSolve<- function(x, ...) {
2522
s <- x$getsolve()
2623
if(!is.null(s)) {
2724
message("getting cached data")
@@ -30,5 +27,5 @@ cacheSolve <- function(x, ...) {
3027
data <- x$get()
3128
s <- solve(data, ...)
3229
x$setsolve(s)
33-
s
30+
s
3431
}

0 commit comments

Comments
 (0)