I've written a little for loop, which is going to iterate over all of the elements in the list.
让我们先看看这儿的代码,我已经写了一个循环语句,用来迭代处理数组中所有的元素。
But you are so busy with your project. You really don't have time to discuss sports.
但是你手头正忙于处理一个项目。你确实没工夫谈运动的话题。
I--You're just off on a different planet in terms of your capacity to process aural material, but we--I can't do that.
我,大家其实到了另外一个星球,要说咱们对声音材料的处理能力,但是我们,我无法做到那样
OK, so far though, I've just shown you what happens inside a peace a code. It raises an exception. It goes to that accept clause. We don't have to use it just inside of one place.
好了,我已经给你们看了,代码内部发生了什么,它报了一个异常,然后就到了处理的片段,我们不该就在一个地方用它。
We need to throw in an extra clause to deal with branching, splitting cases,of the sort that I've just been talking about.
我们需要加一个额外条件,来处理我们上述的分歧案例。
The one problem that we run into is as we go to more and more atoms on the table, as we add on electrons, the Schrodinger equation is going to get more complicated.
我们将会遇到的一个问题,是当我们处理周期表中越来越多的原子时,当我们增加了电子,薛定谔方程,变得愈加复杂。
Where is the button that just says click here to do the most common case?
哪里有一个按钮,当你点击它的时候,它可以处理最通常的情况?
How does Foucault deal with this? He invents a concept.
那么福柯是怎么处理的呢?,他发明了一个理论。
If I talk about it in general terms, they might not put it in that frame Really, an important example of framing is how we deal with money and indexation.
但如果我用简单的话来表述它,他们可能就无法往保险那想,心理框架的另一个重要例子就是,我们是如何处理货币和指数之间的关系。
The way he described is when you try to get down a quantum dimensions and you are standing there with your camera, just remember the sun is at your back and your shadow is always in the picture.
这种方法被他描述为,当你试着处理一个量子尺寸时,并且你试着拿着你的相机在那,记住太阳在你的背后,而你的影子总是在照片上。
What this basically means is, you're given some problem to solve, that you've never seen before.
我们还会再讲讲这些内容,最基本的意思就是你有一个问题要处理。
What does that say? It says if in the code up here I get an exception of that sort, I'm going to go to this place to handle it.
这意味着如果在代码中,我得到一个这样的异常,我能到这里来处理它。
Next we will deal with what's the--arguably-- the single most important thing when we listen to any piece of music and that is its musical form.
接下来我们要处理一个有争议的问题,音乐作品中的最重要的部分是什么,那就是曲式
For a couple of reasons. In some ways, this would be nicer, do expected cases, it's going to tell you on average how much you expect to take, but it tends to be hard to compute, because to compute that, you have to know a distribution on input.
关注最快的情况,在某种意义上来说,因为一些原因这样想挺不错的,当我们处理一个给定的问题,计算平均时间的时候,是很难计算的,因为你并不知道输入的分布情况,这些输入会是怎么样的呢?
So here I've written for the hydrogen atom that deceptively simple form of the Schrodinger equation, where we don't actually write out the Hamiltonian operator, but you remember that's a series of second derivatives, so we have a differential equation that were actually dealing with.
这里我写出了,氢原子薛定谔方程的,最简单形式,这里我们实际上,没有写出哈密顿算符,但是请记住那你有,一系列的二次导数,所有我们实际上会处理一个微分方程。
So, it's a little bit of a trick when you're dealing with ions.
因此,这是一个处理离子问题时的小技巧。
It says you gave me something I didn't know how to deal.
它的意思是你给了编译器一个,他不知道怎么处理的东西。
I just doubled the indentation each time so you can see it. So each successive call, notice what's happening. The argument is getting reduced. And we're going another level in. When we get down to this point, we're calling it with just a string of length one.
因此每次成功调用注意它的过程,我们的命题不断简化,而且我们不断深入嵌套,当我们走到这一步的时候,我们就是在调用它处理,仅有一个元素的字符串了。
So the first one here is something called insertion sort which amounts to going through the list, taking the first thing that you see and inserting that element into its correct place, - then moving on to the next one, dealing with what element-- whatever element you're given and putting it in its right place.
首先是插入排序,在此算法中,需要遍历整个列表,将你遇到的第一个元素放在其正确的位置,然后移动到下一个元素,继续处理-,不管是什么元素,都将其插入到合适的位置。
When we're just interacting with idol, with the interactive editor or sorry, interactive environment if you like, that's what you expect. What's happening is that we're typing in something, an expression it doesn't know how to deal. It's raising the exception, but is this simply bubbling up at the top level saying you've got a problem.
就发生了其中之一是吧,当你在交互数据处理或者是在交互编辑器,抱歉,任何你喜欢的交互式环境中,你可能会遇到这些,如果你在输入什么内容,譬如一个它不知道怎么处理的表达式,它就会报一个异常,但这是否是简单的,把你遇到的问题冒到最顶层呢?
At each stage, no matter which branch, here or here, I take, I'm cutting down the length of the list that I'm searching in half. All right?
选的是这里还是那里,我总是把列表分成两半,对吧?,所以如果我处理一个长度为n的列表?
Last thing to say is why would you want to have exceptions? Well, let's go back to that case of inputting a simple little floating point.
最后要讲的是为什么有异常处理?,回到输入一个简单的小浮点数的例子,如果我期望主要是。
Tim Wakefield Tim Wakefield on the DL right now throws a lot slower, because he has that tricky knuckle ball, he doesn't need to throw as fast.
现在受伤停赛的,投的很慢,因为他有一个很难处理的指节球,他不需要扔的很快。
And so frequently what we try and do is, we take a new problem and map it onto an old problem so that we can use an old solution.
我们经常做的一件事就是,我们处理一个新问题时,把它归结为一个老问题,以便我们能采取老的解决方式。
I'm much better having an exception get handled at the time of input than to let that prop -- that value rather propagate through a whole bunch of code until eventually it hits an error 17 calls later, and you have no clue where it came from.
不是我期望的格式,这时我最好有一个异常处理,而不是让其传下去,这个值传到代码的整个分支,最终会导致一个错误17调用的发生,并且你不知道这个错误是哪里来的。
What that basically says is the following: in an interpreted language, you take what's called the source code, the thing you write, it may go through a simple checker but it basically goes to the interpreter, that thing inside the machine that's going to control the flow of going through each one of the instructions, and give you an output.
也就说,如果是解释语言的话:,你要写一些叫做,源码的东西,你写的东西会经过一个简单的过滤器,然后解释器会处理你的源码,解释器会产生一个,逐条读取你的源码的,控制流,然后返回一个输出结果。
It took me seven comparisons, because I can take advantage of the fact I know I only ever have to look at the first element of each sub-list. Those are the only things I need to compare, and when I run out of one list, I just add the rest of the list in.
进行了7次对比,因为我可以利用我知道的优势:,每次只需要比较每个子列表的第一个元素,那才是我需要进行对比的内容,当一个列表的元素处理完了,只需要将另一个列表剩下的元素直接添加进去。
Why is this much nice? Well, that's a handy piece of code. Because imagine I've got that now, and I can now store that away in some file name, input dot p y, and import into every one of my procedure functions, pardon me, my files of procedures, because it's a standard way of now giving me the input.
为什么这样很好呢?,这是一段很好用的代码,因为想象下如果我有了这段代码,我能把它用某个文件名保存起来,后缀是。py,导入到所有的处理函数中,抱歉,我的处理文件,因为这是一个标准的输入方法。
应用推荐