Skip to content

Commit 9b67cba

Browse files
committed
Se envía el ejercicio
Se envía el ejercicio
1 parent 7f657dd commit 9b67cba

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

cachematrix.R

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
1-
## Put comments here that give an overall description of what your
2-
## functions do
1+
## Archivo que contiene las funciones para generar una matriz y calcular la inversa
32

4-
## Write a short comment describing this function
3+
## Crea una matriz
54

65
makeCacheMatrix <- function(x = matrix()) {
6+
m <- NULL
7+
set <- function(y) {
8+
x <<- y
9+
m <<- NULL
10+
}
11+
get <- function() x
12+
setsolve <- function(solve) m <<- solve
13+
getmean <- function() m
14+
list(set = set, get = get,
15+
setsolve = setsolve,
16+
getsolve = getsolve)
717

818
}
919

1020

11-
## Write a short comment describing this function
21+
## Mete en cache la matriz
1222

1323
cacheSolve <- function(x, ...) {
14-
## Return a matrix that is the inverse of 'x'
24+
## Return a matrix that is the inverse of 'x'
25+
m <- x$getsolve()
26+
if(!is.null(m)) {
27+
message("getting cached data")
28+
return(m)
29+
}
30+
data <- x$get()
31+
m <- solve(data, ...)
32+
x$setsolve(m)
33+
m
1534
}

0 commit comments

Comments
 (0)