Same way that I have multiplication or division as a primitive, functions are going to give me, or somebody else who wrote them for me as part of a library, a new primitive that I'm going to be able to use.
我在用乘法或者除法当做原语,这些函数,或者别人写程序库中的函数,将会给我返回一个,我能使用的新原语。
All right, having said that, let's do some examples. I'm going to show you a sequence of algorithms, they're mostly simple algorithms, that's OK.
好,让我们开始看例子吧,我将会给大家讲,一系列的算法,这些都是挺简单的算法。
I'm going to introduce to you this wonderful new field of positive psychology.
我将会给你们介绍这个积极心理学的精彩的新领域。
X I'm passing an X, and yet I'm also assigning the return value to X. So just intuitively what's going to be the effect of this one line of code?
我传一个X,之后我把返回值赋值给,很明显,这一行代码,将会产生什么作用?
I can give two names, which will get bound to the two parts of that return tuple.
我可以给它设两个变量,返回的一对值将会被赋给这两个变量。
If you give me a number and a string, I'm going to concatenate them together, it's really different operations, but nonetheless, it's what it's going to do.
如果给的输入是一个数字和一个字符串,我将会把它们连接在一起,这实在是不正确的操作,但是无论如何,它就是会去这么做。
I'm going to introduce to you the material.
我将会给你们介绍材料。
And the idea behind recursion I'm going to describe with a simple example. And then I'm going to show you how we can actually use it.
但是为了解释递归的意义,我想举个简单的例子,我将会给你们展示我们该如何使用它。
Computing square root. I'm going to capture it in a piece of code, I'm going to be able to refer to it by a name, and I'm going to suppress the details, meaning inside of that computation, you don't need to know what it does. You just need to know, if I give it the right kind of input, it'll give me back an input that satisfies the contract that I set up.
比如计算平方根,我会用一段代码来说明,我将给它命名,并且忽略细节,意思就是在这一段计算过程中,你不用知道它做了什么,你只需知道,如果我进行了正确的输入,它将会给我符合条件的输出。
And it will just do this ad nauseam until I actually give it an int or if I realize, "Wow, I really screwed up this program.
它将会令人作呕地反复如此处理,直到我给它一个int数或者当我认识到:“喔,我真的弄砸了这个程序。
应用推荐