These things run for variable amounts of time because they take input, a list of size of some amount.
而这一段的执行时间是可变的,因为它们需要输入一个包含一些元素的列表。
So now, henceforth, when you say, to declare a function, I am declaring a function here but down here am I quote unquote defining it or implementing it.
从此以后,当你说,声明一个函数,我在这里声明了一个函数,但是到这里我定义它或执行它。
And I want to remind you, that block of code is a set of instructions, the same set of instructions that are going to be done each time through the loop.
我想提醒大家,这块代码是一个指令集,一个每次循环都会被执行的相同指令集,会变化的仅仅是变量的值。
It's not me. I'm just an instrument of somebody else telling me what to do.
不是我的责任,我只是一个工具,我只是执行别人的命令。
The WHCF in most configurations, usually most effectively in that role, is a staffer.
白宫办公室主任在很多情况下,最充分执行职务的时候,其实是一个职员。
Then they implemented a rule that the guinea is worth twenty-one shillings.
于是政府就执行了一个新令,规定一个几尼值二十一个先令的价值。
Some proteins can be switched from an 'off' position where they don't do anything to an 'on' position where they now do something by only a chemical reaction like this where a phosphorous is added.
一些蛋白质可以从关闭状态的,无所作为,到成为开启状态后,执行某种功能,中间只发生了一个引入磷酸基的化学反应
The sovereign, he says, or Leviathan, this great artificial man, the sovereign is something more like what we would call today an office, rather than a person, as when we speak of the executive as an office.
他说,君主,或者“利维坦,这个人造的人,君主更像是,我们今天称之的“职务“,而不是一个人,就像我们说某个职务的执行官一样。
Towards semester's end you will have the opportunity to choose a project to work on, choose a project that is entirely of your own choice to execute.
接近学期结束时,你们将有机会选择一个项目来做,一个完全由你自己选择执行的项目。
With simple branching, how long is it going to take to run a piece of code?
但是在简单分支程序中,执行一个程序,要多长时间呢?
Now this is not a particularly compelling pace just yet of implementing your own function.
这里没有一个特别的强制性的步骤,来执行你自己的函数。
And inside of the machine, and things we'll talk about, there is a process that will allow that sequence to be executed as described in that recipe, so it can behave like any thing that I can describe in one of those recipes.
在机器里面,还有我们要说的,里面有一个我们允许的,在方法中描述的,将要被执行的序列的过程,因此它可以像我在方法之中,描述的任意一种那样来表现。
So we want to write programs to do that.
为了实现这一目标我们要去写一个执行程序。
And what it's saying semantically is, using that variable as my placeholder, have it walk through this collection, starting at the first thing, execute that code, then the next thing, execute that code, and so on.
它的语义意思就是,把这个变量应用为我的占位符,用它来遍历这个集合,从第一个元素开始,执行代码,然后下一个元素,再执行代码。
Now this happens to be what we would call a linear process, because the number of times I go around the loop is directly related to the size of the argument. If I double 2 the argument, I'm going to double the number of times I go around the loop. If I increase it by five, 5 I'm going to increase by five the number of times I go around the loop.
这恰好是我们会成为,线性复杂度程序的一个例子,因为我要执行循环的次数是,和输入的参数的大小直接相关的,如果我将这个参数乘以,那么我就要将进行循环的次数也乘以2了,如果我把参数加上,那么循环的次数也要加上5了。
So the open curly brace followed by the closed curly brace means everything inside of these curly braces should get executed, but only if that first condition is actually true.
所以左花括号后面跟着,右花括号,这意味着花括号里面所有的代码,都应该是要被执行的,但只有当第一个条件是正确的。
Simply walk down that list.
执行一个直线序列的程序。
It's the first thing that gets executed.
他是开始执行的第一个函数。
Otherwise there's that funky little test.
否则就执行一个挺特别的比较。
But literally all I can do at this stage is write what we would call a straight-line program, that is, a program in which we execute in which we execute the sequence of instructions one by one.
但是字面上来说,我们现在学到的,都是所谓的直线程序,也就是,一个接一个的执行,一系列的,指令的程序。
I'll let you just grok it but you can see it's basically doing what I did over there. Setting up two indices for the two sub-list,it's just walking down, finding the smallest element, putting it into a new list. When it gets to the end of one of the lists, it skips to the next part, and only one of these two pieces will get called because only one of them is going to have things leftovers.
你们可以大体的浏览一下,但是它们基本就是我在那里所做的事情,为两个子列表设置了两个指针,指针顺着列表走下去,找到最小的元素,把它放入到一个新的列表中去,当它走到一个列表的尾部时,它会跳到下部分去,两部分中只有一个会被执行,因为只有一个会有元素剩余。
X So here I'm declaring another variable called X, and this is totally legitimate because I already know that if I'm implementing a function like swap or increment, I can absolutely take input.
这里我声明另一个变量,这个完全是合法的因为我已经知道,如果我执行一个像swap,或,increment的函数,我完全可以携带输入。
And here's a little trick -- and again, we promised to point -- out little tricks of the trade -- if I know I want to execute the last command I typed that started with an m, bangm will actually figure out what that command was and redo it for me so I don't have to figure it out, or you can go back in time in a terminal window.
这里有个小技巧--此外,我们许诺指出行业中的,一些小技巧-,如果我知道我想执行我写入的上一个命令,是以m开头的,!m会明白那个命令是什么,然后为我恢复上次操作,所以我不需要明白它,或者你可以回到,那个终端窗口。
应用推荐