Skip to content
rubenmesteban edited this page Mar 15, 2016 · 5 revisions

makeCacheMatrix <- function(x = matrix()) { inv <- NULL set <- function(y) { x <<- y inv <<- NULL } get <- function() x setinverse <- function(inverse) inv <<- inverse getinverse <- function() inv list(set=set, get=get, setinverse=setinverse, getinverse=getinverse) }

cacheSolve <- function(x, ...) { inv <- x$getinverse() if(!is.null(inv)) { message("getting cached data.") return(inv) } data <- x$get() inv <- solve(data) x$setinverse(inv) inv }

Clone this wiki locally