So in this case, one of the standard ways to do this, is to use what's called a linked list.
标准的处理方法是使用链表,我接下来也准备这么做。
And we're having a difference of opinion as to whether we should use a tuple or a list here, right?
可以“是结果,明白了吗?我们队在这里是应该用数组,还是链表还有一些不同意见对吧?
A particular instance of that is deep versus shallow copy.
一个很好的例子就是深复制和浅复制,当你想要复制一个链表的时候。
But when you pass a parameter say, a list, you didn't think that you were not only passing the list, you were also passing the functions that operate on the list. In fact you are.
你不会认为你输入的不仅仅是链表,你还传递了处理链表的函数,实际上你正是这么做的,这往往不重要。
Let's check it out. I've written a little bit of a test script here, so if we test cell sort, and I've written this so that it's going to print out what the list is at the end of each round, OK.
我们来检查检查,我写了一个小测试脚本,我写这个脚本来测试单元排序,它能够打印出每一轮结束后,链表的是什么样子的。
When you think about an int or a float or a dictionary or a list, you knew that there were functions that operated on them.
当你想到整型,浮点型,或者链表时,你知道可以用函数去处理他们,但是当你传递一个参数,例如链表。
Are you sure you didn't want to do for i in range of list, rather than for i in list?
你真的打算这么做吗?你确定你不是,想在链表范围内定义i而不是定义链表i?
But you'd like to write your program not in terms of floats and ints and lists, but in terms of mortgages, and CDOs, and all of the objects that you read about in the paper, the types you read about.
但是你可以不基于,浮点型,整型还有链表来进行编程,而是基于一些房贷类,债务抵押债券类来编程,甚至那些你在报纸上看到的类。
Alright, so if I'm at the end of the chain, that's my value.
好了,所以如果我,是在链表的最后,这个就是我的总价值了。
For example, the number of elements in the list.
比方说链表中的元素个数。
So let's think about lists. So if l is a list, l sort I can call something like s dot sort, l dot sort.
所以让我们想想链表,所以如果l是一个,链表我可以调用像是s,sort的函数。
Or a list of anything that could be mutable.
或者是包含其它有可变的结果的链表。
And then we looked at this little loop before, for i in range number of stocks, I'm going to create two different lists of stocks, one where the moves, or distributions, are chosen from a uniform, and the other where they're Gaussian.
这里的这个小循环,因为i代表股票,我会建立两个不同的股票链表,一个是代表股票价格的移动,或者说是分布,它们是从均匀分布中得出的,而另一个链表是从高斯分布中得出的。
应用推荐