Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions cachematrix.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
## Put comments here that give an overall description of what your
## functions do
## We need to write two functions that will cache the inverse of a matrix x
## we will use the example that it was provided

## Write a short comment describing this function
## makeCacheMatrix - creates a matrix obj where the cache is the inverse of the input

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)

}


## Write a short comment describing this function
## cacheSolve - computes the inverse and returns it, if the inverse was already computed,
##then the function should return the inverse from the cache

cacheSolve <- function(x, ...) {
## Return a matrix that is the inverse of 'x'
inv<- x$getInverse()
if(!is.null(inv)){
message("getting cached data")
return(inv)}
m<- x$get()
inv <- solve(m,...)
x$setInverse(inv)
inv

}
4 changes: 4 additions & 0 deletions sum_two_numbers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sumTwoNumbers <- function(a, b) {
a + b
}