Skip to content

ysy_assignment #5412

Open
Open
@Lilian221111

Description

@Lilian221111

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)

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      ysy_assignment · Issue #5412 · rdpeng/ProgrammingAssignment2