Now formally I could have had this pointing off to another object containing 4, but that just seemed excessive, right?
当然我可以正式的把它指向,另外一个含有4的对象,但这有点多余对不对?
So I mean philosophy can talk about how do we know we got a table here between us. Right?
比如,哲学可以告诉我们是怎么感知到,我们之间有一个桌子,对不对?
And because, as long as this collection is finite, this thing is just going to walk through. All right?
这个操作就会遍历完它的,对不对?,那么,如果我给大家看看,例如?
Now,it's very tempting at this point to say,look,of course Nothing could be easier ? Just imagine being in heaven forever,right?
现在我很想说,当然了,这没什么难的,只要想象永远在天堂就行了对不对?
The technical expression of that in philosophy is common knowledge, which I can never spell, so I'm going to wing it.
在哲学上叫做共同知识,我不知道拼写对不对,我看一下
But it turns out that as we'll see that functions absolutely take arguments, right?
但结果是我们将看到,函数绝对是有参数的,对不对?
I said that if I was really hygienic, and you can now wonder about how often do I shower?
但是这真的很棒,对不对?,那么为什么我要说这些呢?,我说过如果我真的很讲卫生的话?
Yeah. So the answer, in case you didn't hear it, was, again, if I'm a gambling person, I could start like a way down here.
答案是,如果我是一个赌徒,我可以再这边开始对不对?,如果我在赌博,我会说,嘿。
So the first thing we'll do is, we'll print the element, in this case it will be a list right? Because it's a list with two lists in it.
因此这儿我们要做的第一件事,就是要显示元素,在这儿元素就是数组了对不对?,因为这个数组包含了两个数组。
It seems to me that Princeton University had a reputation nationally for a country club environment whether that was ever legitimate, which I don't think so.
我觉得普林斯顿大学,在国内都被称为有着乡村俱乐部的氛围,先不管这么说对不对,我本人是持否定意见。
OK. I get the two values in, what do I need to do, well, you sort of know that, right?
好,有了这两个输入值了,我接下来将要做的,你知道对不对?
In terms of primitive data, what we saw were two kinds: Right?
在基础数据方面,我们上节课学了两种类型对不对?
On the other hand, if the value I'm looking for here- sorry, the value I'm looking for is smaller than the value I see here, I just need to look here. All right?
如果我的目标数比这个值要小呢?,我就在这边找就对了,对不对?,做完了这一步,我可以在下一步做相同的操作,假设我选中了这一分支?
The last thing I want to point out to you is, I started out with this list. I haven't added anything to the list, right? I mean I've got a different kind of looping mechanism.
我们从这个列表开始,我没往这个列表上加任何东西对不对?,我的意思是我学会了一种不同种类的,循环机制,我想我得说。
And the problem is, that we want to build this abstract data type, but we'd like to basically know what kind of object is it, and what functions actually belong to it, how do we use them?
然后我对它们运行了这个方法,就是这一小段代码这个方法,这有意义么?,当然没有了,对不对?,因为你知道,当你把两个极坐标,表示的点进行相加运算的时候?
So what would I want to do? I'd like to somehow walk down each of the digits one at a time and add them up. Ah, that's a looping mechanism, right? I need to have some way of walking through them.
去取这个数的,每个数字然后把他们加起来,啊,这是个循环机制对不对?,我得找到一个遍历它们的方法,一种简单的方法可能。
Whereas the list assignment you see here did not rebind the object l 1, it changed this. OK?
并没有对包含1的对象做重新绑定,所以这有所改变,对不对?
So if we look at what we've got here, we've got something rather peculiar, right? What's peculiar about what this computer is now printing for us?
那么如果我们看看,现在我们得到的,结果的话,结果相当奇怪,对不对?计算机现在显示的结果?
Let's search to see though now if a million is in this list, or 10 million, whichever way I did this it must be a million, right?
不管我选哪个,数都挺大的对不对?,用嘴基本的方法,噢,花的时间有点长,好,而用二分法呢?
And there's res. Never type kneeling. Right?
这里有很多有趣的中间值对不对?
I'm going to set up an index, which is going to tell me where to look, starting at the first part of the list, right?
索引告诉我从哪里开始检索数组,对不对?,然后我会去记录下我做了多少次比较,这样我就能看到这个算法的工作量了?
It's words to you, or to the reader of the code, that are telling you what's going on inside of this code. OK?
注释是一些对你,或者对代码阅读者说的一些话,告诉你这段代码,是干什么的,对不对?
All right? I mean, I can make money at Harvard Square doing this stuff, right?
对不对?【鼓掌】我意思是,我可以在哈佛广场,靠做这个赚钱对不对?
And then we'll see if it is. So I think I put in one a two, right? Or one a two?
我认为我们把1a2放进了数组对不对?,那么显示结果应该是1,a,2了?
This is another way of doing exponentiation, but this one's a recursive function. All right?
但这是一种递归的方法对不对?,好,让我们看看这种方法?
And it's primarily-- I shouldn't say primarily, it is an interpreted language. OK?
它基本上-我不该说基本上的,它就是一种解释语言,对不对?
So when I'm done, I'm going to give the value back out. All right?
当它完成计算后,需要返回个值对不对?
Well, I could look at the value here, and compare it to the value I'm trying to find, and say the following; if the value I'm looking for is bigger than this value, where do I need to look? Just here.
然后把它和目标数做个比较,然后做出如下的判断:,如果目标值大于这个值;,那么我应该去哪找呢?对,应该在这里,对不对?不可能在那儿。
All right? What's the value of that expression?
对不对?这个表达式的值是多少?
I can do division, right? Whoa. Right?
我也可以做除法对不对?
应用推荐