Am I crazy? R looks like Javascript?

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?

Compartilhe este insight:

2 respostas

  1. Cool! I write a lot of JS in my day job; R bears a resemblance.

    p.s. I’m enjoying your flurry of English blog posts.

    p.p.s. English tip: That last sentence sounds a little broken. Might be better phrased: “This code reminds me of JavaScript.”

    Hope to see you again, my friend. Peace

    1. Hello friend,

      I decided to blog in English to improve my English skills. Besides of that, I really enjoy the idea of sharing my thoughts with friends like you.

      Thanks. I just changed the post.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Elemar Júnior

Sou fundador e CEO da EximiaCo e atuo como tech trusted advisor ajudando diversas empresas a gerar mais resultados através da tecnologia.

Elemar Júnior

Sou fundador e CEO da EximiaCo e atuo como tech trusted advisor ajudando diversas empresas a gerar mais resultados através da tecnologia.

Mais insights para o seu negócio

Veja mais alguns estudos e reflexões que podem gerar alguns insights para o seu negócio:

Internalizei a definição de liderança do professor Falconi: Liderança significa bater metas, com o time, fazendo o certo. Assim como...
In the previous post, I mentioned Mario Fusco who wrote a blog post series questioning the way Java developers are...
[tweet]Aprenda comigo técnicas de modelagem de bancos de dados de documentos NoSQL e a utilizar o RavenDB[/tweet] – um dos...
In a previous post, I started an elementary search library using C#. Now, I will improve it adding a Porter...
Limpar strings é uma tarefa comum em nossas aplicações. Entretanto, .NET torna fácil cometer erros de implementação que levam a...
In the previous post, I asked why the following code behaves differently when compilation is made in Release and Debug...
× Precisa de ajuda?