[Which of the following could be simplified or removed without changing the result?]
So you may already have a good intuition for these sorts of optimizations.
Let me give you a chance to show that off.
So here I've written a function in JavaScript called Plato's Republic.
It's a function of 2 variables: A and B.
A gets A times 1, B gets B + 0, A gets A + B,
B gets B + 2, and then finally we return A.
There are 5 possible statements here.
Which of them can be simplified or removed
without changing the result?
And here I really want you to mostly focus on removing,
and note that this is a little trickier than it looks.
So give it some thought.
このような種類の最適化には
直観が働くようになってきたかもしれません
実際にやって確かめてみましょう
JavaScriptで関数platos_republicを書きました
aとbの2つの引数を取る関数です
a=a*1;b=b+0;a=a+b;
b=b+2;そして最後にaを返します
選択肢が5つあります
結果を変えずに取り除けるのはどれでしょうか?
取り除くことだけを考えてください
見た目よりも難しいです
考えてみてください
Quais dos seguintes poderiam ser simplificados, ou removidos, sem que o rtesultado seja alterado?
Pode ser que você jé tenha uma boa intuição sobre esse tipo de otimizações.
Deixe-me dar a você um chance de mostrar isso.
Escrevi aqui um função em JavaScript, chamada platos_republic.
É uma função de 2 variáveis: a e b.
a = a*1; b = b+0; a = a+b;
b = b+2 e, finalmente, retornamos A.
Existem 5 possíveis comandos aqui.
Quais podem ser simplificados ou removidos,
sem que o resultado seja alterado?
E aqui eu realmente quero que voc6e foque mais em remoção.
E note que isso é um pouco mais complicado do que parece.
Portanto, pense um pouco.