So, I decided to learn how to code using R. That’s something I wrote:
## defining a function
makeCacheMatrix <- function(x = matrix()) {
## internal state
inv <- NULL
## defining some closures
set <- function(y) {
x <<- y
inv <<- NULL
}
get <- function() x
setinverse <- function(inverse = matrix()) inv <<- inverse
getinverse <- function() inv
## returning functions as an object
list(
set = set,
get = get,
setinverse = setinverse,
getinverse = getinverse
)
}
Am I crazy? This code remembers me of JavaScript. Do you agree with that?