So let's address this by considering another example, which should clarify what the difference is between these ionization energies.
让我们用另外一个例子来讲一讲这个问题,这应该能够说清楚,各个电离能之间的区别。
In another example, you can use a "when" question in order to ask about the timing of a specific event.
在下面这个例子中,你可以用When 问句来询问一个具体活动的时间。
In fact, this example would compile because you can use curly braces in this way to encapsulate lines of code, but realize for now, that, not good.
实际上,这个例子可以编译,因为你可以用这种方式来压缩代码行,但是请认识到,那个,不太好。
PROFESSOR: And so in this case, it's using the same piece, but it's returning that middle value that says they're actually the same.
教授:那么实际在这个例子中,我们用的是同一个函数,它返回了中间的值也就是,0来表明着两个参数。
In the case of a recursive exponentiator, I'm going to do the following trick.
在这个迭代求乘方的例子里面,我会用这么个小把戏。
Again as I said this is my version of it, but you can see, every one of the examples we've used so far has that pattern to it.
形成了迭代的思想,我还是想用我的话,来表达表达,但是你们可以看到,我们讲过的每个例子都用到了这个模式。
Not so easy to see. All right, but this is actually a great one of those educational moments. This is a great example to think recursively. If I wanted to think about this problem recursively- what do I mean by thinking recursively?
看不太出来,好,但实际上是一个有教育意义的时刻,这是一个很好的关于递归的例子,如果我用递归的思想,去考虑这个问题-,我该怎么用递归去解决这个问题呢?
And the reason I want to use this as an example is, here's my little definition of segment.
我为什么要用这个,做为这个例子的原因是,这是我对于segment的一个小定义。
And that's a wonderful thing to have because it gives you that modularity, that encapsulation that basically says, when I create a point, the only way I can get at the values, is by using one of the defined methods, in this case it could be Cartesian, Cartesian and get all the pieces of that.
这是很棒的一件事情,因为它让你有了,模块性以及封装性,这基本上也就是说,当我创建了一个点,我能够得到它的值的唯一的方式,就是用一个定义好的方法,在这个例子中也就是。
I spotted an error here, I could have spotted it by running it on different test sets, and using prints things, another way of doing it, but this idea of at least simulating it on simple examples lets you check a couple of important questions.
操作么?我在这里发现了一个错误,我也可以通过运行不同的测试集,或者运用print声明来发现这个错误,但是至少应该用简单的例子来手工模拟下,代码的思想可以让你,对一些很重要的问题进行检验。
b OK. In this example I'd use b. All right, as b get-- b is the thing that's changing as I go along here, but it could be things like, how many elements are there in a list if the input is a list, could be how many digits are there in a string if the input's a string, it could be the size of the integer as we go along. All right.?
好,在这个例子里我会用,因为b是一直在变的东西,但是也可能是如下情况:,如果输入是数组的话,变化的就是数组的元素数,如果输入是字符串的话,变化的就是字符串的长度,如果是integer的话,可能就是这个数的大小,对不对?
应用推荐