It is going to give me back a tuple a collection of two things, and so check out the syntax.
它将给我返回一个数组或者系列的一对值,然后检查一下语法。
So for example I defined p, remember back over here, as a Cartesian point, but I can actually ask for its polar form.
我可以要求返回它的极坐标形式,这里对我是可访问的,好,这很棒,请再记另外一个为什么。
Well, I'm going to get back, let's just draw a bigger square than usual that's roughly four times the size.
嗯,返回的是,我画一个更大的方形,大致上是4倍的大小。
I'm going to come back to the example that was raised before.
我要返回去探讨之前的一个例子。
She says, just stay with me and I--you will live forever and all will be well and he says, well, you're a very beautiful girl and I enjoy you a lot, but I got to go back to Ithaca.
女神说,留下来,我赐你长生不老,终生美好,但奥德修斯拒绝了,虽然您的魅力让我倾心,但我不得不返回伊萨卡岛
Notice one last piece. If I'm going to do that, run through all possible answers, I still want to know, gee, what if there aren't any answers? How do I return that case?
注意最后一段,如果我要这样做,也就是运行所有可能的答案,我还是想知道要是没有结果呢?,在这个例子中应该返回什么呢?
Then if the weight of i is less than the available weight, I can return the value of i.
然后如果i的重量,小于剩下的重量,我将返回i的价值。
I first tested it on the square root of 4 and in one iteration it found 2.
我首先测了下求4的平方根4,它只迭代了一次并返回了2。
So what I wanted to do is loop back, at least with a couple of things that we see recurring and very understandably so, but let's try to clear up a couple of frequently occurring issues.
所以我想要做的是回环,至少用两三个,我们看到的东西返回,并且可以理解地,让我们试着处理几个,频繁发生的事情。
They only need to have values if you care GetInt about getting something back from them, get int, swap you care about its value; but swap, I don't want to hear it again.
它们只需要拥有值,如果你关心,它们的返回值,你关心它的返回值,但是,我不想再得到它的返回。
Do one comparison and return one of two possible orders on it, but I need to decide that.
虽然可以做一次比较,然后返回两个可能的顺序中的一个为结果,但是这需要我来做决定。
So that's the second thing I've just highlighted here, is that I now have the ability to check whether it does the right thing.
你知道的,一个虚数,但是返回虚数就没有什么价值了,那么这是我想要强调的第二件事情。
It'd still give me an answer. It just would not be the answer I'm looking for.
然后运行程序,程序还是会返回一个答案,只是不是我想要的答案。
That is to say, I'm going to go back to a node I've already visited.
也就是说我将要,返回我访问过的节点。
So the first thing it does, price=0 is it says, if self dot price is 0, I'm just going to return.
所以它做的第一件事就是,如果self。,我就返回。
So when I said earlier that as soon as swap returns, all of the memory allocated for swap is now useless.
我前面指明的,一旦swap返回,所有为swap分配的内存都是无用的了。
All right, I want to show you one last example of using recursion because we're going to come back to this. This is a classic example of using recursion. And that is dating from the 1200s and it is due to Fibonacci.
并且返回答案,我想给你看看递归的最后一个例子,因为我们还要再看一遍,这是一个递归的经典案例,它可以追溯到13世纪。
Which is sort of the question we'd immediately like to ask. Instead, I asked why did it produce the result it did. So I'm not asking myself what's wrong? Or how could I make it right?
其实这个问题我们马上就要问,我问了为什么它会返回这样的结果,因此我并没有去在意哪儿错了,或者我该怎么改正它,我在意的是它?
But here's a new and improved, I think, version of increment; ++ returns nothing, takes nothing, but it does perform plus plus, but I did something stupid.
但这里是一个新的,改进了的increment版本;,没返回值,没输入值,但它执行的是,但是我做了件愚蠢的事情。
But it's a valuable thing. It says, in each case, I return some useful value from this procedure.
但是这就是变量,是在每个例子中,我从这个程序中返回了一些有用的值。
But I got a couple of other of these strange looking things in there with underbars to them.
我可以在这片代码中看到这些,然后我需要一些可以给我,返回这些信息的东西,但是这里还有一些看起来。
I can use that to return values, which I can then use elsewhere, which I did-- and if I just come back and highlight this-- inside of that computation.
我可以用它来返回值,然后我可以在别的地方使用这些返回值,正是我做的--如果我回过头来,在高亮一下这个--在这部分计算内部。
I don't have to go read what it printed out in the screen. This has returned a value that I can use. Because I could do a test to say, is this a return value? If it's not, I'll do something else with it. So the binding is still there, it simply doesn't print it out.
我不想读到屏幕中打印出来的这行字,程序返回过一个我能够使用的值,因为我可以做个小测试,来说明这是否是返回的值,如果不是,我可以做一些其它的事,而这个绑定依然在这儿,没有打印任何东西。
So the first thing I'm going to do is, I'm going to try and return the value in the memo.
所以我要做的第一件事,就是我将会尝试将,总价值返回到memo中。
I'm going to print here the list if we go into it, and print of the when we're done and then just return that.
注意接下我来我要做的事,运行到这里时会打印列表,并且当处理完成后会打印返回的列表。
So I can similarly do this, which is going to look strange because it's going to give me the same value back out, but it actually did a slightly different thing.
我也可以通过类似的手段来达到这个目的,这看起来很奇怪,但是会返回相同的值,但是它的实现真的有点不同。
p1 But if I say, are p 1 and p 2 the same point, it says yes.
和p2是不是同一个点,It,says,no。,返回的结果是肯定的,在这里我有个要强调的点,这个例子里发生的是。
And it probably, I think we can deduce, returns the right answer here.
然后程序也可能,我认为我们可以推断,程序会返回正确的答案。
And then I'll create this function, d1 this distribution d 1, which will, whenever I call it, give me a random, a uniformly selected value between minus and plus volatility.
然后我会创建这个函数,这个概率分布,每次我调用这个函数的时候,他会给我返回一个随机的,按照均匀分布,从正负浮动值之间选择的值。
Again I should have said first, index 0, the first one. I can similarly go in and say I'd like all the things between index 2 and index 4. And again, remember what a b c that does. Index 2 says start a 0. 1, 2. So a, b, c.
我还是要说一遍,索引为0的元素,是第一个元素,我可以要求返回索引,2和4之前的所有元素,请记住2,是从0开始的,那么0,1,2对应的是。
应用推荐