If I want to create a set or a sequence representing these things, I simply insert into that list.
如果我想创建一个集合,或者一个序列表示这些东西,我只要简单的把它插入列表中。
I would love to run a program for actors to teach them
我想创建一个项目,让演员们
When I call or invoke a function, think of it as creating a local table.
当我调用一个函数时,想象一下它是在这里创建了一个局部表。
I've been working with the Chicago Mercantile Exchange to create a futures market for single-family homes, which is sort of my connection to the futures industry.
我一直以来和芝加哥商业交易所合作,创建一个适合单一家庭的期货市场,这是我参与期货行业的一种方式
So there we have, I'll create a GUI interface using Visual Basic, see if I can track an IP address.
好了,我用VB创建一个,图形用户界面,看是否可以跟踪IP地址。
If I had had a clean interface, that I had a specific method to get those values out, I wouldn't have to change anything.
如果之前我创建了,一个清楚的借口,也就是我有特定的,取得这些值的方法的话。
This is a little file I created, all right, and I'm going to start with a sequence of these things and walk them along, again I invite you to put comments on that handout so that you can follow what we're going to do. All right?
这是我创建的一个小文件,好,然后我回去以一系列这样的事情,开始然后进行下去,我还是想大家都在手册上做一些注释,这样我们就能对将要做的事情,做一个记录了,对不对?
I'm going to build a list. Right, you can see that little loop going through there.
我要创建一个列表,是的,你可以看到这里有一个小小的循环。
And when I create a binding, x I'm taking a variable name, in this case x, stored somewhere in a table, and I'm creating a link or a pointer from that name to that value.
当我创建一个绑定的时候,我有一个变量的名字,在这个例子中是,存在一个表中的某处,然后创建一个连接,或者指针从这个名字指向目标值。
So, what's the idea? If I know what my hash function does, it maps, in this case characters into a range zero to 256, which is zero to 255, I create a list that long, and I simply mark things.
我知道我的哈希函数做什么,在这个例子中,它将字母,映射成0到255的256个数字,我创建了一个这么长的列表,并且我只是简单的标志这些东西。
I've got a little program called Silly.
我创建了一个名为Silly的小程序。
So, for example, if I say TEST and I don't give it a start but I give it an end, then it gives me all the elements up to that point.
例如,我创建了TEST这个元组我没有给他,起始点却给了它一个结束点,然后程序会基于这一点放置所有的元素。
I'll create a GUI interface using Visual Basic, see if I can track an IP address.
我用VB创建一个图形用户界面,试试能不能跟踪IP地址。
And I want to show you a little bit more detail of that, so let's create a simple little list here.
我还想给你们再讲详细些,那让我们来创建一个简单的列表吧。
Now I have the ability to say, I've got a new class, I can create instances of a line segment, and it's elements are themselves instances of points. OK?
这就是我们要讲模块化的地方了,现在我可以说,我创建了一个新类,我可以创建线段的实例了,这些实例的元素?
But there's actually hidden in there an important element, and that is, when I create an instance, I have to be able to get access to the things that characterize that instance.
也就是,当我创建了一个实例,我应该能够获得那些特性化,这个实例的东西,我的意思不是说它们是想法,或者情绪之类的。
So now here's the idea. I build a list 256 elements long, and I fill it up with those special characters none.
所以这里就是这种思想6,我创建了一个可以放下256个元素的列表,然后我以这些没有实际意义的字符将其填充。
OK, so as I said, now I can go off and I could create a different class.
好,正如我所说,现在我可以进行下去,去创建一个不同的类了。
Constant. Ooh, constant says, no matter what the length of the list is, I'm going to take the same amount of time.
这个算法用的时间是相同的,我不这么认为,如果我们创建一个十倍于以前大小的数组。
Let me give you, I'm going to create, q a polar point, I'm going to call it q, and we'll give it some random values.
让我给大家讲解下,我要去创建,一个极坐标点,然后我会去命名它为,然后我给它赋一些随机的值,好,现在我想知道。
same point Cartesian to have 1 representation for a point that supports different ways of getting information out, but has gathered within it, a method or a function for dealing with things like how do I know if it's the same point or not.
还有,这是一个比较极坐标的点,是否相同的不同的方法,但是这开始成了一个麻烦事儿了,我真正想要做的事情是,创建一个能支持不同的方式,输出已经收集的信息的点的表示。
Now what I'd like to do, every time I find a divisor I'd like to gather it together. So I'm going to create a tuple of one element, the value of i.
那么我就会去创建只包含一个元素的元组,也就是这个除数了,然后,啊,很好,这里是加法重载的一个很糟糕的应用。
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've got Cartesian points, I could create a polar points.
我已经有了一些笛卡尔坐标点了,我可以创建一个极坐标点。
So this first little piece of code right here says, ok you give me 2 points, I'll create another 1 of these lists and I'll simply take the x, sorry I shouldn't say x, I'm going to assume it's the x, the x-values are the two points, add them together, just right there, the y-values, add them together and return that list.
好,为了来认识到这一点,让我们来看一个简单的小例子,在你们的课堂手册上,你可以看到我写了一个小程序,它假设我得到了,这些点中的一些,我想对它们做一些操作,例如我想把它们加到一起,那么这里的第一小片,代码的意思是,好给我两个点,我会再创建一个数组。
I'm returning that as my set.
所以我在创建一个列表。
What we're really getting at is the idea of saying I want to have a way of grouping together information into units that make sense. So I can go back to one of those topics we had at the beginning, which is the idea of abstraction, that I can create one of those units as a simple entity, bury away the details and write really modular code.
组合成为有意义的单元,那么这就让我们回到,一开始讲的话题之一了,这就是抽象的概念,也就是我可以以一个简单的,实体的形式创建这样的一个单元,把具体实现隐藏然后写一些,真正模块化的代码,我们在以后的课程中。
What am I doing? I'm creating a list with just that special symbol none in it.
我在做什么?,我只是在创建一个,有着特殊标记。
And I'm going to initialize it, create them, with an opening price.
我要对它进行初始化,给它们一个初始价格然后创建它们。
I did not want to make a list, I wanted to create a tuple thank you for catching it. I want parens not square brackets there.
为什么这里有错误了,我并不想要创建,一个列表,我想创建一个元组,谢谢你,发现了这个错误。
应用推荐