diff --git a/Lexical scoping b/Lexical scoping new file mode 100644 index 00000000000..43c42838538 --- /dev/null +++ b/Lexical scoping @@ -0,0 +1,25 @@ +makecachematrix<- function (x = matrix()){ +inv<- NULL +set<-function(y){ +x<<-y +inv<<-NULL +} +get<-function() x +setInverse<- function() inv<<-solve(x) +getInverse<- function() inv +list(set = set, +get = get, +setInverse = setInverse, +getInverse = getInverse) +} +cachemean<- function (x,...) { +inv<-x$getInverse() +if(!is.null(inv)){ +message("getting cached data") +return(inv) +} +data <-x$get() +inv <- Inverse(data,...) +x$setInverse(inv) +inv +}