Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ysy_assignment #5412

Open
Lilian221111 opened this issue Jul 23, 2022 · 0 comments
Open

ysy_assignment #5412

Lilian221111 opened this issue Jul 23, 2022 · 0 comments

Comments

@Lilian221111
Copy link

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

cacheSolve <- function(x, ...) {
ivs <- x$getinverse()
if (!is.null(ivs)){
# get it from the cache and skips the computation.
message("getting cached data")
return(ivs)
}

data = x$get()
ivs <- solve(data, ...)
x$setinverse(ivs)

return(ivs)

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant