OK? So you can see that, it's just walking through it, and in fact if I look at a couple of another-- another couple of examples, it's been a long day, again, you can see that property.
恩,其实你能看到,他就是遍历列表,你要有空的话,可以再看很多很多其他的例子,你能够看到这个属性。
I want to abstract that. And the abstraction you see, right here. I'm going to highlight it for a second so you can see it. I want you to look at it on the handout as well.
我需要进行抽象,这个抽象就在这儿,我把它强调给你们看看,我希望你也能看看讲义里的这部分内容。
I brought the text with me. You can look at it now or at your leisure.
我带来了这部作品,你们可以看看,现在或者是有空时。
Can I get you all to look at Game 1 and start thinking about it.
大家先浏览下游戏1 然后思考一下
Yeah, I like to look at films in different ways, because you can look at one film and explore it like the music. For example, in Film Music we looked at Psycho which I see on the syllabus, and we talked about the music in that film.
是的,我喜欢从不同的角度研究电影,因为你可以看一部电影,从音乐的角度研究它,例如,我看到教学大纲上有《精神病患者》,在电影音乐课上我们看了这部电影,并讨论了电影中的配乐。
Now, this is not the nicest way to do it but it'll work. I can look at the type of the value of base and compare it to the type of an actual float and see, are they the same?
这不是最好的办法但它确实有用,我可以得到底的值的类型然后,和一个真的浮点数的类型比比,看他们是不是一样?
Meaning, I'm just going to write a little loop that does that. All right, so let's go back to our code. That's right, let me pull this over a little bit, so I can see it. And what I'd like you to look at, I'm going to highlight it just for a second here, is those two pieces of code.
意思就是我只需,写一个小循环就可以了,让我们回到代码,让我们向下拉一点,我才看得见,我希望你看看这里。
OK, and if I wanted to look at it, we can come back over here, and we can see what does c p 1 look like, interesting.
现在对于这里的每个实例,我都赋了x和y值,好,那么如果我想要研究下它,我们可以回到这里来。
I can either look at my flow chart, or I can look at the code. If I look at the flow chart, it says, I'm at this point. Look at ANS squared. Is it less than or equal to-- sorry, first of all, 0 ANS squared is 0, is it less than or equal to x, yes.
我可以看流程图也可以看我的代码,如果我看流程图的话,流程图这么说的,在这一点,看看ANS的平方,看是不是小于等于-对不起,首先,ANS的平方是。
So I'm going to go over here, and I'm going to type test search-- I can type and if you look at your handout, it's just a sequence of tests that I'm going to do OK. So initially, I'm going to set up the list to be the first million integers.
大家可以看看你们的课堂材料,那儿有一些我要做的实验,好,一开始我先去建立个,含有一百万个integer的数组,对,这有点儿简单,但是这给我提供了这样一个有序的数组。
All right? So if I called sqrt alone, that return test value is done, but in this case I bound it to test, so I can go look at test, and there it is.
执行完返回值语句,但是在这里我将把它赋值给,所以当我看test的值的时候就是返回的值。
应用推荐