What is that? It's the piece of code we wrote for computing square roots, square roots of actually perfect squares.
对吧?这是什么呢?,这是我们写的计算平方根的代码,计算完全全平方根的。
All right, this is actually a very old piece of imperative knowledge for computing square roots, it's attributed to Heron of Alexandria, although I believe that the Babylonians are suspected of knowing it beforehand.
好,这是一个很古老的,关于计算平方根的程序性知识,是亚历山大的海伦提出的,不过我怀疑在那之前,巴比伦人就已经猜想过了。
Suppose I want to compute square roots a lot of places in a big chunk of code.
假设我想在一大段代码中,计算很多次平方根。
I can check it, so if this was part of some other computation, I want to know, did it find a perfect square or not?
我可以检验它,因此如果这是其它计算的一部分我想知道,它能否找到一个完全平方根呢?
Computing square root. I'm going to capture it in a piece of code, I'm going to be able to refer to it by a name, and I'm going to suppress the details, meaning inside of that computation, you don't need to know what it does. You just need to know, if I give it the right kind of input, it'll give me back an input that satisfies the contract that I set up.
比如计算平方根,我会用一段代码来说明,我将给它命名,并且忽略细节,意思就是在这一段计算过程中,你不用知道它做了什么,你只需知道,如果我进行了正确的输入,它将会给我符合条件的输出。
应用推荐