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倍的大小。
false It's going to return true if it's a PAIL-indrome and false if it's a PAL-indrome. And it says true. Now maybe you're bugged by this.
如果不是会问的话则是,返回的是真值,那么你可能会觉得这个很烦。
The Republic belongs to that period of Plato's work after his return to Athens, after the execution of Socrates.
理想国》即是柏拉图,在返回雅典后的作品之一,也就是在苏格拉底被处决之后。
I'm going to go away from studying imperfect competition and go back and visit something we studied almost the first day or maybe the second day, and that election.
我将放下不完全竞争,而是返回去讲我们几乎是第一天,或者是第二天学习的一些内容,就是选举
1%10 So if you actually do in a program 11 percent 10, 1 what you'll get back is 1 because that is in fact the remainder of that arithmetic operation.
如果在编程里就是,返回,因为1是这个计算式的余数。
4 So even if the correct mathematical answer is 1.4 or whatever, when you divide an int by an int, you only have room in that variable, in the response for an actual integer.
所以即使那个正确的答案是4,或别的数值,当你用一个整型数除以一个整型数,在那个变量的返回值里,只有,存储一个整型数的空间。
So you're implementing this black box, and if its purpose in life is to actually return a value, you have to tell the compiler what kind of value to expect, and this is going to have ripple effects.
你在实现这个黑盒子,如果它的目的是,返回一个值,你必须告诉编译器你期望的是什么类型的值,这个将是一个连锁反应。
This is saying, that's a class, true or sorry, an instance of a class, and I'm going to get the x value associated with it.
那么两个点是同一个点,我会返回,注意格式,这儿的意思是,它是一个类,噢对不起。
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.
所以我想要做的是回环,至少用两三个,我们看到的东西返回,并且可以理解地,让我们试着处理几个,频繁发生的事情。
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.
你知道的,一个虚数,但是返回虚数就没有什么价值了,那么这是我想要强调的第二件事情。
You know when you add 2 polar forms, you add the radii together, you don't add the angles together, you need to do it in Cartesian form.
表示形式的不同理解,返回给你了不同的值,这也就带来了一系列的问题,第二个问题是。
It says, well I'm going to print out first and last just so you can see it, and then I say, gee 2 if last minus first is less than 2, that is, if there's no more than two elements left in the list, then I can just check those two elements and return the answer.
然后它计算了尾点和开始点的差,如果小于2的话,也就是说数组中的元素小于等于,我对这两个元素进行比较,然后返回结果就可以了,否则的话,我们就去寻找中值点,注意它是怎么实现的,首先这个指向一个列表的开头。
p1 But if I say, are p 1 and p 2 the same point, it says yes.
和p2是不是同一个点,It,says,no。,返回的结果是肯定的,在这里我有个要强调的点,这个例子里发生的是。
I get a key error. Because, remember, these things are not ordered.
程序会返回一个键错误,因此,记住字典里的元素是无序的。
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?
其实这个问题我们马上就要问,我问了为什么它会返回这样的结果,因此我并没有去在意哪儿错了,或者我该怎么改正它,我在意的是它?
i-1 But with index i minus 1.
但是同时返回的是索引号。
It's totally legit to cull a function, get back a value, do nothing with it other than compare it to another value.
挑选一个函数是完全合法的,返回一个值,用它来做些事情而不是用它与其它的值比较。
Is it one basically? In which case, just return a copy the list. That's the simple case.
是最基本的情况吗?在这种情况下,仅仅返回一个列表的拷贝,这是简单的情况。
Something that takes two inputs, a left operant - and a right operant and it just returns a Boolean value is-- or rather it returns a left to right value.
它有两个输入,一个是左边的作用物,一个是右边的作用物,然后返回一个布尔值-,或者更确切地说,返回一个从左到右的值。
This just means hexadecimal notation, which we'll come back to before long so really it just means it's returning the 0 address zero.
这表示的是16进制,我们等下还会讨论,表示的是返回,地址。
PROFESSOR: And so in this case, it's using the same piece, but it's returning that middle value that says they're actually the same.
教授:那么实际在这个例子中,我们用的是同一个函数,它返回了中间的值也就是,0来表明着两个参数。
So the end result, because someone wrote this function years ago is that printf takes this thing, takes this thing, David plops David inside the middle of that formatted string and then renders the whole result.
基于这是某人多年以前写的程序,最终的结果是打印出这个,这个,在格式化字符串中间的,然后返回结果。
Second thing we saw is, that using this as a computation, I can return multiple values.
我们看到的第二件事是把它用作计算,我可以返回多个值。
Well I'm relying on the contract, if you like, that the manufacturer of square root put together, which is, if I know I'm giving it two floats, which I do because I make sure they're floats, the contract, if you like, of square root says I'll give you back a float.
好吧我能靠一些类似合约来保证,如果这么说你喜欢的话,其实就是当求平方根的方法,获得了两个我已经确认了是浮点数的数后,这个类似合约的东西就会保证,返回一个浮点数。
The only thing that you have to put in the function prototype, ; again, is three things; one, the name of the function; the return value; and its arguments.
你唯一要加入到函数原型中的东西,是有三个东西,一,函数的名字;,返回值,和它的参数。
And those are two things that you'd like to do with every looping construct you write: you'd like to be able to assure yourself that they will always terminate, and then the second thing you'd like to do, is to assure yourself that it does give you back a reasonable answer.
就是现在我有了能去检查程序,是不是做了正确的操作的能力:,这就是你们在写每个循环程序的时候,都要注意的两个事情:,第一件事情是要确保程序可以终结,第二件你要做的事情,就是要确保程序返回了正确的答案。
What that basically says is the following: in an interpreted language, you take what's called the source code, the thing you write, it may go through a simple checker but it basically goes to the interpreter, that thing inside the machine that's going to control the flow of going through each one of the instructions, and give you an output.
也就说,如果是解释语言的话:,你要写一些叫做,源码的东西,你写的东西会经过一个简单的过滤器,然后解释器会处理你的源码,解释器会产生一个,逐条读取你的源码的,控制流,然后返回一个输出结果。
应用推荐