1 Star 0 Fork 0

jacklisp/Learning-SICP

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lec3a.eng.ass 95.52 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
[Script Info]
; Script generated by Aegisub 3.0.4
; http://www.aegisub.org/
Title: SICP
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
Collisions: Normal
Last Style Storage: Default
Audio URI: G:\untitled\ref\lec3a_480_muxed.mp4
Video Zoom Percent: 0.625
Scroll Position: 507
Active Line: 512
Video File: G:\untitled\ref\lec3a_480_muxed.mp4
Video Aspect Ratio: c1.33333
Video Position: 18119
PlayResX: 640
PlayResY: 480
YCbCr Matrix: TV.601
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: EN,Calisto MT,21,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
Style: Declare,微软雅黑,30,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,2,0,8,10,10,10,1
Style: staff,微软雅黑,30,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,0,2,5,10,10,10,1
Style: title,微软雅黑,35,&H001D64D9,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,0,1,5,10,10,10,1
Style: Default,雅黑宋体,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,1,0,2,10,10,30,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:03.12,Declare,,0,0,0,,{\an2\fad(500,500)}Learning-SICP Group
Dialogue: 0,0:00:04.40,0:00:08.02,Declare,,0,0,0,,{\an2\fad(500,500)}Translation && Timeline: Dysprosium / Savior Michael\NEncode && Effects: Dysprosium
Dialogue: 0,0:00:08.06,0:00:12.16,Declare,,0,0,0,,{\an2\fad(500,500)}Credit: Prof. Qiu Zongyan
Dialogue: 0,0:00:12.37,0:00:16.32,Declare,,0,0,0,,{\an2\fad(500,500)}Henderson-Escher Example
Dialogue: 0,0:00:20.94,0:00:23.86,EN,,0,0,0,,PROFESSOR: Well, last time we talked about compound data,
Dialogue: 0,0:00:24.94,0:00:29.74,EN,,0,0,0,,and there were two main points to that business.
Dialogue: 0,0:00:29.74,0:00:32.48,EN,,0,0,0,,First of all, there was a methodology of data abstraction,
Dialogue: 0,0:00:32.94,0:00:39.10,EN,,0,0,0,,and the point of that was that you could isolate the way that data objects are used
Dialogue: 0,0:00:40.06,0:00:41.50,EN,,0,0,0,,from the way that they're represented:
Dialogue: 0,0:00:41.55,0:00:45.20,EN,,0,0,0,,this idea that there's this guy, George, and you go out make a contract with him;
Dialogue: 0,0:00:45.20,0:00:47.48,EN,,0,0,0,,and it's his business to represent the data objects;
Dialogue: 0,0:00:47.48,0:00:49.36,EN,,0,0,0,,and at the moment you are using them,
Dialogue: 0,0:00:49.36,0:00:51.36,EN,,0,0,0,,you don't think about George's problem.
Dialogue: 0,0:00:51.98,0:00:58.44,EN,,0,0,0,,And then secondly, there was this particular way that Lisp has of gluing together things
Dialogue: 0,0:00:58.94,0:01:00.52,EN,,0,0,0,,to form objects called pairs,
Dialogue: 0,0:01:00.52,0:01:03.54,EN,,0,0,0,,and that's done with cons, car and cdr.
Dialogue: 0,0:01:03.54,0:01:07.16,EN,,0,0,0,,And the way that cons, car and cdr are implemented is basically irrelevant.
Dialogue: 0,0:01:07.16,0:01:10.02,EN,,0,0,0,,That's sort of George's problem of how to build those things.
Dialogue: 0,0:01:10.02,0:01:11.16,EN,,0,0,0,,It could be done as primitives.
Dialogue: 0,0:01:11.16,0:01:13.80,EN,,0,0,0,,It could be done using procedures in some weird way,
Dialogue: 0,0:01:13.80,0:01:15.22,EN,,0,0,0,,but we're not going to worry about that.
Dialogue: 0,0:01:16.02,0:01:19.66,EN,,0,0,0,,And as an example, we looked at rational number arithmetic.
Dialogue: 0,0:01:19.66,0:01:21.50,EN,,0,0,0,,We looked at vectors,
Dialogue: 0,0:01:21.50,0:01:24.18,EN,,0,0,0,,and here's just a review of vectors.
Dialogue: 0,0:01:24.18,0:01:27.64,EN,,0,0,0,,Here's an operation that takes the sum of of two vectors,
Dialogue: 0,0:01:27.64,0:01:33.32,EN,,0,0,0,,so we want to add this vector, v1, and this vector, v2, and we get the sum.
Dialogue: 0,0:01:34.46,0:01:40.84,EN,,0,0,0,,And the sum is the vector whose coordinates are the sum of the coordinates of the pieces you're adding.
Dialogue: 0,0:01:41.28,0:01:45.66,EN,,0,0,0,,So I can say, to define make-vect, right, to add two vectors
Dialogue: 0,0:01:45.66,0:01:51.72,EN,,0,0,0,,I make a vector, whose x coordinate is the sum of the two x coordinates,
Dialogue: 0,0:01:52.10,0:01:54.82,EN,,0,0,0,,and whose y coordinate is the sum of the two y coordinates.
Dialogue: 0,0:01:56.06,0:02:04.10,EN,,0,0,0,,And then similarly, we could have an operation that scales vectors,
Dialogue: 0,0:02:04.94,0:02:12.66,EN,,0,0,0,,so here's a procedure scale that multiplies a vector, v, by some number, s.
Dialogue: 0,0:02:13.08,0:02:16.14,EN,,0,0,0,,So here's v, v goes from there to there
Dialogue: 0,0:02:16.32,0:02:20.22,EN,,0,0,0,,and I scale v, and I get a vector in the same direction that's longer.
Dialogue: 0,0:02:21.56,0:02:24.26,EN,,0,0,0,,And again, to scale a vector, I multiply the successive coordinates.
Dialogue: 0,0:02:24.26,0:02:30.22,EN,,0,0,0,,So I make a vector, whose x coordinate is the scale factor times the x coordinate
Dialogue: 0,0:02:30.56,0:02:33.54,EN,,0,0,0,,and whose y coordinate is the scale factor times the y coordinate.
Dialogue: 0,0:02:33.54,0:02:40.28,EN,,0,0,0,,So those are two operations that are implemented using the representation of vectors.
Dialogue: 0,0:02:40.28,0:02:45.02,EN,,0,0,0,,And the representation of vectors, for instance, is something that we can build in terms of pairs.
Dialogue: 0,0:02:45.34,0:02:51.28,EN,,0,0,0,,So George has gone out and implemented for us make-vector and x coordinate and y coordinate,
Dialogue: 0,0:02:53.02,0:02:57.98,EN,,0,0,0,,and this could be done, for instance, using cons,car and cdr;
Dialogue: 0,0:02:58.88,0:03:06.78,EN,,0,0,0,,and notice here, I wrote this in a slightly different way.
Dialogue: 0,0:03:08.04,0:03:11.00,EN,,0,0,0,,The procedures we've seen before, I've said something like
Dialogue: 0,0:03:11.14,0:03:16.22,EN,,0,0,0,,say, make-vector of x and y: cons of x and y.
Dialogue: 0,0:03:16.22,0:03:17.98,EN,,0,0,0,,And here I just wrote make-vector cons.
Dialogue: 0,0:03:17.98,0:03:20.48,EN,,0,0,0,,And that means something slightly different.
Dialogue: 0,0:03:20.48,0:03:26.22,EN,,0,0,0,,Previously we'd say, define make-vector to be a procedure that takes two arguments, x and y,
Dialogue: 0,0:03:26.22,0:03:28.04,EN,,0,0,0,,and does cons of x and y.
Dialogue: 0,0:03:28.04,0:03:34.12,EN,,0,0,0,,And here I am saying define make-vector to be the thing that cons is,
Dialogue: 0,0:03:35.18,0:03:39.66,EN,,0,0,0,,and that's almost the same as the other way we've been writing things.
Dialogue: 0,0:03:39.66,0:03:46.58,EN,,0,0,0,,And I just want you to get used to the idea that procedures can be objects, and that you can name them.
Dialogue: 0,0:03:48.70,0:03:51.80,EN,,0,0,0,,OK, well there's vector representation, and again,
Dialogue: 0,0:03:51.80,0:03:55.68,EN,,0,0,0,,if that was all there was to it,this would all be pretty boring.
Dialogue: 0,0:03:57.02,0:04:02.16,EN,,0,0,0,,And the point is, remember, that you can use cons to glue together not just numbers to form pairs,
Dialogue: 0,0:04:02.16,0:04:04.16,EN,,0,0,0,,but to glue together arbitrary things.
Dialogue: 0,0:04:05.20,0:04:11.60,EN,,0,0,0,,So for instance, if we'd like to represent a line segment,
Dialogue: 0,0:04:11.60,0:04:15.64,EN,,0,0,0,,say the line segment that goes from a certain vector:
Dialogue: 0,0:04:16.06,0:04:28.30,EN,,0,0,0,,say, the segment from the vector 2,3 to the point represented by the vector 5,1.
Dialogue: 0,0:04:28.30,0:04:31.82,EN,,0,0,0,,If we want to represent that line segment,
Dialogue: 0,0:04:33.26,0:04:36.20,EN,,0,0,0,,then we can build that as a pair of pairs.
Dialogue: 0,0:04:40.72,0:04:42.94,EN,,0,0,0,,So again, we can represent line segments.
Dialogue: 0,0:04:42.94,0:04:47.34,EN,,0,0,0,,We can make a constructor that makes a segment using cons,
Dialogue: 0,0:04:47.98,0:04:51.60,EN,,0,0,0,,selects out the start of a segment, selects out the end point of the segment;
Dialogue: 0,0:04:55.24,0:04:59.76,EN,,0,0,0,,and then if we actually look at that, if we peel away the abstraction layers,
Dialogue: 0,0:04:59.88,0:05:02.10,EN,,0,0,0,,and see what's that really is a pair of pairs,
Dialogue: 0,0:05:04.66,0:05:06.22,EN,,0,0,0,,we'd say well that's a pair.
Dialogue: 0,0:05:06.22,0:05:08.22,EN,,0,0,0,,Here's the segment.
Dialogue: 0,0:05:10.00,0:05:16.72,EN,,0,0,0,,It's car, right, it's car pointer is a pair, and it's cdr is also a pair,
Dialogue: 0,0:05:18.32,0:05:25.54,EN,,0,0,0,,and then what the car is--here's the car, that itself is a pair of 2 and 3.
Dialogue: 0,0:05:26.02,0:05:28.08,EN,,0,0,0,,And similarly the cdr is a pair of 2 and 3.
Dialogue: 0,0:05:28.16,0:05:29.24,EN,,0,0,0,,And let me remind you again
Dialogue: 0,0:05:29.32,0:05:33.46,EN,,0,0,0,,that a lot of people have some idea that if I'd taken this arrow and somehow
Dialogue: 0,0:05:33.80,0:05:36.90,EN,,0,0,0,,written it to point down, that would mean something else.
Dialogue: 0,0:05:36.98,0:05:38.28,EN,,0,0,0,,That's irrelevant.
Dialogue: 0,0:05:38.58,0:05:43.90,EN,,0,0,0,,It's only how these are connected and not whether this arrow happens to go vertically or horizontally.
Dialogue: 0,0:05:47.48,0:05:52.18,EN,,0,0,0,,And again just to remind you, there was this notion of closure.
Dialogue: 0,0:05:52.94,0:06:05.62,EN,,0,0,0,,See, closure was the thing that allowed us to start building up complexity, that didn't trap us in pairs.
Dialogue: 0,0:06:06.64,0:06:15.24,EN,,0,0,0,,Particularly what I mean is the things that we make, having combined things using cons to get a pair,
Dialogue: 0,0:06:16.44,0:06:22.64,EN,,0,0,0,,those things themselves can be combined using cons to make more complicated things.
Dialogue: 0,0:06:23.28,0:06:31.98,EN,,0,0,0,,Or as a mathematician might say, the set of data objects in Lisp is closed under the operation of forming pairs.
Dialogue: 0,0:06:33.82,0:06:36.34,EN,,0,0,0,,That's the thing that allows us to build complexity.
Dialogue: 0,0:06:36.34,0:06:38.04,EN,,0,0,0,,And that seems obvious, but remember
Dialogue: 0,0:06:39.06,0:06:42.46,EN,,0,0,0,,a lot of the things in the computer languages that people use are not closed.
Dialogue: 0,0:06:42.46,0:06:48.06,EN,,0,0,0,,So for example, forming arrays in Basic and Fortran is not a closed operation,
Dialogue: 0,0:06:48.08,0:06:51.94,EN,,0,0,0,,because you can make an array of numbers or character strings or something,
Dialogue: 0,0:06:52.04,0:06:54.18,EN,,0,0,0,,but you can't make an array of arrays.
Dialogue: 0,0:06:54.64,0:06:56.68,EN,,0,0,0,,And when you look at means of combination
Dialogue: 0,0:06:57.60,0:07:02.78,EN,,0,0,0,,you should be asking yourself whether things are closed under that means of combination.
Dialogue: 0,0:07:05.06,0:07:08.26,EN,,0,0,0,,Well in any case, because we can form pairs of pairs,
Dialogue: 0,0:07:08.86,0:07:12.78,EN,,0,0,0,,we can start using pairs to glue things together in all sorts of different ways.
Dialogue: 0,0:07:14.02,0:07:18.26,EN,,0,0,0,,So for instance if I'd like to glue together the four things, 1, 2, 3 and 4,
Dialogue: 0,0:07:18.26,0:07:19.82,EN,,0,0,0,,there are a lot of ways I can do it.
Dialogue: 0,0:07:20.74,0:07:26.12,EN,,0,0,0,,I could, for example, like we did with that line segment, i could make a pair
Dialogue: 0,0:07:29.02,0:07:36.88,EN,,0,0,0,,that had a 1 and a 2 and a 3 and a 4, right?
Dialogue: 0,0:07:36.88,0:07:40.06,EN,,0,0,0,,Or if I liked, I could do something like this.
Dialogue: 0,0:07:40.06,0:07:45.52,EN,,0,0,0,,I could make a pair, whose first thing is a pair,
Dialogue: 0,0:07:46.44,0:07:53.20,EN,,0,0,0,,whose car is 1, and his cdr is itself a pair that has the 2 and the 3
Dialogue: 0,0:07:53.26,0:07:55.08,EN,,0,0,0,,and then I could put the 4 up here.
Dialogue: 0,0:07:56.92,0:08:02.16,EN,,0,0,0,,So you see, there are a lot of different ways that I can start using pairs to glue things together,
Dialogue: 0,0:08:02.16,0:08:07.74,EN,,0,0,0,,and so it'll be a good idea to establish some kind of conventions,right,
Dialogue: 0,0:08:07.74,0:08:11.58,EN,,0,0,0,,that allow us to deal with this thing in some conventional way,
Dialogue: 0,0:08:11.58,0:08:14.00,EN,,0,0,0,,so we're not constantly making an ad hoc choice.
Dialogue: 0,0:08:15.94,0:08:19.04,EN,,0,0,0,,And Lisp has a particular convention
Dialogue: 0,0:08:20.74,0:08:25.82,EN,,0,0,0,,for representing a sequence of things as, essentially, a chain of pairs,
Dialogue: 0,0:08:26.78,0:08:28.18,EN,,0,0,0,,and that's called a List.
Dialogue: 0,0:08:34.72,0:08:40.50,EN,,0,0,0,,And what a list is is essentially just a convention for representing a sequence.
Dialogue: 0,0:08:40.70,0:08:47.38,EN,,0,0,0,,I would represent the sequence 1, 2, 3 and 4 by a sequence of pairs.
Dialogue: 0,0:08:48.26,0:08:54.68,EN,,0,0,0,,I'd put 1 here and then the cdr of this would point to another pair
Dialogue: 0,0:08:59.20,0:09:01.40,EN,,0,0,0,,whose car was the next thing in the sequence,
Dialogue: 0,0:09:01.52,0:09:03.42,EN,,0,0,0,,and the cdr would point to another pair
Dialogue: 0,0:09:05.44,0:09:07.30,EN,,0,0,0,,whose car was the next thing in the sequence--
Dialogue: 0,0:09:07.36,0:09:08.44,EN,,0,0,0,,so there's 3--
Dialogue: 0,0:09:08.44,0:09:09.74,EN,,0,0,0,,and then another one.
Dialogue: 0,0:09:09.74,0:09:13.22,EN,,0,0,0,,So for each item in the sequence, I'll get a pair.
Dialogue: 0,0:09:15.82,0:09:18.32,EN,,0,0,0,,And now there are no more, so I put a special marker
Dialogue: 0,0:09:20.72,0:09:22.74,EN,,0,0,0,,that means there's nothing more in the List.
Dialogue: 0,0:09:24.14,0:09:34.64,EN,,0,0,0,,OK, so that's a conventional way to glue things together if you want to represent a sequence, right.
Dialogue: 0,0:09:34.64,0:09:37.98,EN,,0,0,0,,And what it is is a bunch of pairs,
Dialogue: 0,0:09:39.40,0:09:44.80,EN,,0,0,0,,the successive cars of each pair are the items that you want to glue together,
Dialogue: 0,0:09:46.00,0:09:48.46,EN,,0,0,0,,and the cdr pointer points to the next pair.
Dialogue: 0,0:09:50.02,0:09:56.04,EN,,0,0,0,,Now if I actually wanted to construct that, what I would type into Lisp is this:
Dialogue: 0,0:09:56.62,0:09:58.76,EN,,0,0,0,,I'd actually construct that as saying, well this thing is
Dialogue: 0,0:09:59.22,0:10:15.28,EN,,0,0,0,,the cons of 1 onto the cons of 2 onto the cons of 3 onto the cons of 4 onto, well, this thing nil.
Dialogue: 0,0:10:15.28,0:10:20.00,EN,,0,0,0,,And what nil is is a name for the end of List marker.
Dialogue: 0,0:10:20.80,0:10:23.24,EN,,0,0,0,,It's a special name, which means this is the end of the List.
Dialogue: 0,0:10:26.24,0:10:30.26,EN,,0,0,0,,OK, so that's how I would actually construct that.
Dialogue: 0,0:10:37.54,0:10:41.40,EN,,0,0,0,,Of course, it's a terrible drag to constantly have to write something like
Dialogue: 0,0:10:41.45,0:10:45.18,EN,,0,0,0,,the cons of 1 onto the cons of 2 onto the cons of 3, whenever you want to make this thing.
Dialogue: 0,0:10:45.18,0:10:50.10,EN,,0,0,0,,So Lisp has an operation that's called LIST,
Dialogue: 0,0:10:53.70,0:10:57.72,EN,,0,0,0,,and List is just an abbreviation for this nest of conses.
Dialogue: 0,0:10:58.96,0:11:06.32,EN,,0,0,0,,So I could say, I could construct that by saying that is the List of 1, 2, 3 and 4.
Dialogue: 0,0:11:07.78,0:11:11.74,EN,,0,0,0,,And all this is is another way, a piece of syntactic sugar,
Dialogue: 0,0:11:11.94,0:11:14.76,EN,,0,0,0,,a more convenient way for writing that chain of conses--
Dialogue: 0,0:11:14.76,0:11:17.84,EN,,0,0,0,,cons of cons of cons of cons of cons of cons onto nil.
Dialogue: 0,0:11:18.48,0:11:39.78,EN,,0,0,0,,So for example, I could build this thing and say, I'll define 1-TO-4 to be the List of 1, 2, 3 and 4.
Dialogue: 0,0:11:47.96,0:11:53.02,EN,,0,0,0,,OK, well notice some of the consequences of using this convention.
Dialogue: 0,0:11:53.80,0:11:56.92,EN,,0,0,0,,First of all if I have this List, this 1, 2, 3 and 4,
Dialogue: 0,0:11:57.36,0:12:02.64,EN,,0,0,0,,the car of the whole thing is the first element in the List, right.
Dialogue: 0,0:12:04.06,0:12:05.28,EN,,0,0,0,,How do I get 2?
Dialogue: 0,0:12:05.28,0:12:23.94,EN,,0,0,0,,Well, 2 would be the car of the cdr of this thing 1-TO-4, it would be 2, right.
Dialogue: 0,0:12:23.98,0:12:29.48,EN,,0,0,0,,I take this thing, I take the cdr of it, which is this much,
Dialogue: 0,0:12:29.82,0:12:31.68,EN,,0,0,0,,and the car of that is 2,
Dialogue: 0,0:12:32.58,0:12:47.42,EN,,0,0,0,,and then similarly, the car of the cdr of the cdr of 1-TO-4, cdr, cdr, car--
Dialogue: 0,0:12:47.42,0:12:51.36,EN,,0,0,0,,would give me 3, and so on.
Dialogue: 0,0:12:52.68,0:12:55.84,EN,,0,0,0,,Let's take a look at that on the computer screen for a second.
Dialogue: 0,0:12:57.50,0:13:11.18,EN,,0,0,0,,I could come up to List, and I could type define 1-TO-4 to be the List of 1, 2, 3 and 4, right.
Dialogue: 0,0:13:13.78,0:13:21.28,EN,,0,0,0,,And I'll tell that to Lisp, and it says, fine, that's the definition of 1-TO-4.
Dialogue: 0,0:13:22.30,0:13:36.74,EN,,0,0,0,,And I could say, for instance, what's the car of the cdr of the cdr of 1-TO-4, close paren, close paren.
Dialogue: 0,0:13:38.34,0:13:42.42,EN,,0,0,0,,Right, so the car of the cdr of the cdr would be 3.
Dialogue: 0,0:13:44.08,0:13:50.08,EN,,0,0,0,,Right, or I could say, what's 1-TO-4 itself.
Dialogue: 0,0:13:51.26,0:13:57.22,EN,,0,0,0,,And you see what Lisp typed out is 1, 2, 3, 4, enclosed in parentheses,
Dialogue: 0,0:13:57.22,0:14:02.12,EN,,0,0,0,,and this notation, typing the elements of the List enclosed in parentheses
Dialogue: 0,0:14:02.12,0:14:08.90,EN,,0,0,0,,is Lisp's conventional way for printing back this chain of pairs that represents a sequence.
Dialogue: 0,0:14:08.90,0:14:17.14,EN,,0,0,0,,So for example, if I said, what's the cdr of 1-TO-4,
Dialogue: 0,0:14:19.30,0:14:21.12,EN,,0,0,0,,that's going to be the rest of the List.
Dialogue: 0,0:14:21.32,0:14:26.96,EN,,0,0,0,,That's the thing pointed to by the first pair, which is, again, a sequence that starts off with 2.
Dialogue: 0,0:14:28.52,0:14:37.74,EN,,0,0,0,,Or for example, I go off and say, what's the cdr of the cdr of 1-TO-4;
Dialogue: 0,0:14:43.24,0:14:44.68,EN,,0,0,0,,then that's 3,4.
Dialogue: 0,0:14:44.82,0:14:59.66,EN,,0,0,0,,Or if I say, what's the cdr of the cdr of the cdr of the cdr of 1-TO-4,
Dialogue: 0,0:15:04.74,0:15:10.46,EN,,0,0,0,,and I'm down there looking at the end of List pointer itself, and Lisp prints that as just open paren, close paren.
Dialogue: 0,0:15:10.96,0:15:13.48,EN,,0,0,0,,You can think of that as a List with nothing in there.
Dialogue: 0,0:15:14.12,0:15:21.38,EN,,0,0,0,,All right, see at the end what I did there was I looked at the cdr of the cdr of the cdr of 1-TO-4,
Dialogue: 0,0:15:21.42,0:15:25.20,EN,,0,0,0,,and I'm just left with the end of List pointer itself.
Dialogue: 0,0:15:25.20,0:15:27.20,EN,,0,0,0,,And that gets printed as open close.
Dialogue: 0,0:15:34.14,0:15:39.98,EN,,0,0,0,,All right, well that's a conventional way you can see for working down a List
Dialogue: 0,0:15:41.50,0:15:43.44,EN,,0,0,0,,by taking successive cdrs of things.
Dialogue: 0,0:15:43.44,0:15:45.00,EN,,0,0,0,,It's called cdring down a List.
Dialogue: 0,0:15:46.64,0:15:49.78,EN,,0,0,0,,And of course it's pretty much of a drag to type all those cdrs by hand.
Dialogue: 0,0:15:49.78,0:15:52.24,EN,,0,0,0,,You don't do that. You write procedures that do that.
Dialogue: 0,0:15:52.96,0:15:59.10,EN,,0,0,0,,And in fact one very, very common thing to do in Lisp is to write procedures that,
Dialogue: 0,0:15:59.85,0:16:06.54,EN,,0,0,0,,sort of, take a List of things and do something to every element in List, and return you a List of the results.
Dialogue: 0,0:16:07.42,0:16:11.92,EN,,0,0,0,,So what I mean for example, is I might write a procedure called Scale-List,
Dialogue: 0,0:16:16.80,0:16:25.24,EN,,0,0,0,,and Scale-List I might say I want to scale by 10 the entire List 1-TO-4,
Dialogue: 0,0:16:26.66,0:16:35.32,EN,,0,0,0,,and that would return for me the List 10, 20, 30, 40.
Dialogue: 0,0:16:38.25,0:16:40.25,EN,,0,0,0,,Right, it returns List, and
Dialogue: 0,0:16:44.49,0:16:49.30,EN,,0,0,0,,well you can see that there's going to be some kind of recursive strategy for doing it.
Dialogue: 0,0:16:49.30,0:16:51.30,EN,,0,0,0,,How would I actually write that procedure?
Dialogue: 0,0:16:52.52,0:16:59.80,EN,,0,0,0,,The idea would be, well if you'd like to build up a List where you've multiplied every element by 10,
Dialogue: 0,0:17:00.44,0:17:04.84,EN,,0,0,0,,what you'd say is well you imagine that you'd taken the rest of the List--
Dialogue: 0,0:17:05.86,0:17:08.42,EN,,0,0,0,,right, the thing represented by the cdr of the List,
Dialogue: 0,0:17:08.42,0:17:14.16,EN,,0,0,0,,and suppose I'd already built a List where each of these was multiplied by 10--
Dialogue: 0,0:17:16.06,0:17:19.68,EN,,0,0,0,,that would be Scale-List of the cdr of the List.
Dialogue: 0,0:17:20.12,0:17:23.82,EN,,0,0,0,,And then all I have to do is multiply the car of the List by 10,
Dialogue: 0,0:17:24.89,0:17:27.24,EN,,0,0,0,,and then cons that onto the rest, and I'll get a List.
Dialogue: 0,0:17:29.02,0:17:33.09,EN,,0,0,0,,Right and then similarly, to have scaled the cdr of the List, I'll scale the cdr of that
Dialogue: 0,0:17:33.30,0:17:36.20,EN,,0,0,0,,cons onto that 2 multiplied by 10.
Dialogue: 0,0:17:36.42,0:17:41.16,EN,,0,0,0,,And finally when I get all the way down to the end, and I only have this end of List pointer.
Dialogue: 0,0:17:41.72,0:17:45.28,EN,,0,0,0,,All right, this thing whose name is nil-- well I just returned an end of List pointer.
Dialogue: 0,0:17:45.54,0:17:47.68,EN,,0,0,0,,So there's a recursive strategy for doing that.
Dialogue: 0,0:17:47.68,0:17:50.52,EN,,0,0,0,,Here's the actual procedure that does that.
Dialogue: 0,0:17:50.96,0:17:55.04,EN,,0,0,0,,Right, this is an example of the general strategy of cdr-ing down a List and
Dialogue: 0,0:17:55.66,0:17:58.24,EN,,0,0,0,,so called cons-ing up the result, right.
Dialogue: 0,0:17:58.24,0:18:06.04,EN,,0,0,0,,So to Scale a List l by some scale factor s, what do I do?
Dialogue: 0,0:18:06.04,0:18:10.40,EN,,0,0,0,,Well there's a test, and Lisp has the predicate called null.
Dialogue: 0,0:18:10.40,0:18:13.22,EN,,0,0,0,,Null means is this thing the end of List pointer,
Dialogue: 0,0:18:13.90,0:18:17.16,EN,,0,0,0,,or another way to think of that is are there any elements in this List, right.
Dialogue: 0,0:18:18.17,0:18:23.00,EN,,0,0,0,,But in any case if I'm looking at the end of List pointer, then I just return the end of List pointer.
Dialogue: 0,0:18:23.65,0:18:24.60,EN,,0,0,0,,I just return nil,
Dialogue: 0,0:18:24.94,0:18:35.14,EN,,0,0,0,,otherwise I cons together the result of doing what I'm going to do to the first element in the List,
Dialogue: 0,0:18:35.54,0:18:39.29,EN,,0,0,0,,namely taking the car of l and multiplying it by s,
Dialogue: 0,0:18:40.36,0:18:46.34,EN,,0,0,0,,and I cons that onto recursively scaling the rest of the List.
Dialogue: 0,0:18:49.98,0:18:52.18,EN,,0,0,0,,OK, so again, the general idea is that you
Dialogue: 0,0:18:52.22,0:18:56.09,EN,,0,0,0,,you recursively do something to the rest of the List, to the cdr of the List,
Dialogue: 0,0:18:56.48,0:19:01.16,EN,,0,0,0,,and then you cons that onto actually doing something to the first element of the List.
Dialogue: 0,0:19:01.16,0:19:05.18,EN,,0,0,0,,When you get down to the end here, you return the end of List pointer,
Dialogue: 0,0:19:07.34,0:19:11.36,EN,,0,0,0,,and that's a general pattern for doing something to a list.
Dialogue: 0,0:19:14.05,0:19:19.52,EN,,0,0,0,,Well of course you should know by now that the very fact
Dialogue: 0,0:19:19.53,0:19:22.62,EN,,0,0,0,,that there's a general pattern there means I shouldn't be writing this procedure at all.
Dialogue: 0,0:19:22.62,0:19:24.90,EN,,0,0,0,,What I should do is write a procedure
Dialogue: 0,0:19:24.90,0:19:26.32,EN,,0,0,0,,that's the general pattern itself
Dialogue: 0,0:19:26.80,0:19:30.30,EN,,0,0,0,,that says, do something to everything in the List and define this thing in terms of that.
Dialogue: 0,0:19:30.68,0:19:32.30,EN,,0,0,0,,Right, make some higher order procedure,
Dialogue: 0,0:19:32.32,0:19:35.18,EN,,0,0,0,,and here's the higher order procedure that does that. It's called MAP,
Dialogue: 0,0:19:36.73,0:19:43.17,EN,,0,0,0,,and what MAP does is it takes a List, takes a List l, and it takes a procedure p,
Dialogue: 0,0:19:44.92,0:19:51.08,EN,,0,0,0,,and it returns the List of the elements gotten by applying p to each successive element in the List.
Dialogue: 0,0:19:51.81,0:19:55.40,EN,,0,0,0,,All right, so p of e1, p of e2, p of en.
Dialogue: 0,0:19:55.64,0:20:01.54,EN,,0,0,0,,Right, so I think of taking this List and transforming it by applying p to each element.
Dialogue: 0,0:20:02.52,0:20:07.08,EN,,0,0,0,,And you see all this procedure is is exactly the general strategy I said.
Dialogue: 0,0:20:07.08,0:20:09.08,EN,,0,0,0,,Instead of multiply by 10, it's do the procedure.
Dialogue: 0,0:20:09.08,0:20:11.64,EN,,0,0,0,,If the List is empty, return nil.
Dialogue: 0,0:20:11.86,0:20:16.60,EN,,0,0,0,,Otherwise, apply p to the first element of the List.
Dialogue: 0,0:20:17.14,0:20:18.74,EN,,0,0,0,,Right, apply p to car of l,
Dialogue: 0,0:20:19.30,0:20:25.40,EN,,0,0,0,,and cons that onto the result of applying p to everything in the cdr of the List,
Dialogue: 0,0:20:25.61,0:20:28.84,EN,,0,0,0,,so that's a general procedure called MAP.
Dialogue: 0,0:20:29.86,0:20:39.04,EN,,0,0,0,,And I could define Scale-List in terms of MAP.
Dialogue: 0,0:20:39.04,0:20:41.04,EN,,0,0,0,,Let me show you that first.
Dialogue: 0,0:20:43.46,0:20:52.50,EN,,0,0,0,,But I could say Scale-List is another way to define it is just MAP along the List by the procedure,
Dialogue: 0,0:20:52.50,0:20:55.54,EN,,0,0,0,,which takes an item and multiplies it by s.
Dialogue: 0,0:20:58.96,0:21:01.90,EN,,0,0,0,,Right, so this is really the way I should think about scaling the List,
Dialogue: 0,0:21:02.12,0:21:07.40,EN,,0,0,0,,build that actual recursion into the general strategy, not to every particular procedure I write.
Dialogue: 0,0:21:07.40,0:21:11.28,EN,,0,0,0,,And of course, one of the values of doing this is that you start to see commonality.
Dialogue: 0,0:21:12.16,0:21:15.02,EN,,0,0,0,,Right, again you're capturing general patterns of usage.
Dialogue: 0,0:21:15.96,0:21:31.18,EN,,0,0,0,,For instance, if I said MAP, the square procedure, down this List 1-TO-4, then I'd end up with 1, 4, 9 and 16.
Dialogue: 0,0:21:32.48,0:21:37.17,EN,,0,0,0,,Right, or if I said MAP down this List,
Dialogue: 0,0:21:37.57,0:21:46.32,EN,,0,0,0,,lambda of x plus x 10, if I MAP that down 1-TO-4,
Dialogue: 0,0:21:49.68,0:21:52.86,EN,,0,0,0,,then I'd get the List where everything had 10 added to it:
Dialogue: 0,0:21:53.34,0:21:58.17,EN,,0,0,0,,right, so I'd get 11,12, 13, 14.
Dialogue: 0,0:22:00.56,0:22:05.76,EN,,0,0,0,,And you can see that's going to be a very, very common idea: doing something to every element in the List.
Dialogue: 0,0:22:08.66,0:22:12.22,EN,,0,0,0,,One thing you might think about is writing MAP in an iterative style.
Dialogue: 0,0:22:12.22,0:22:16.04,EN,,0,0,0,,The one I wrote happens to evolve a recursive process,
Dialogue: 0,0:22:16.36,0:22:19.10,EN,,0,0,0,,but we could just as easily have made one that evolves an iterative process.
Dialogue: 0,0:22:19.10,0:22:23.16,EN,,0,0,0,,But see the interesting thing about it is that once you start thinking in terms of MAP--
Dialogue: 0,0:22:24.02,0:22:29.00,EN,,0,0,0,,see, once you say scale is just MAP, you stop thinking about whether it's iterative or recursive,
Dialogue: 0,0:22:29.00,0:22:31.82,EN,,0,0,0,,and you just say, well there's this aggregate, there's this List,
Dialogue: 0,0:22:32.22,0:22:34.52,EN,,0,0,0,,and what I do is transform every item in the List,
Dialogue: 0,0:22:34.56,0:22:38.36,EN,,0,0,0,,and I stop thinking about the particular control structure in order.
Dialogue: 0,0:22:38.88,0:22:41.09,EN,,0,0,0,,That's a very, very important idea,
Dialogue: 0,0:22:42.36,0:22:46.48,EN,,0,0,0,,and it, I guess it really comes out of APL.
Dialogue: 0,0:22:46.48,0:22:49.10,EN,,0,0,0,,It's, sort of, the really important idea in APL
Dialogue: 0,0:22:49.12,0:22:51.13,EN,,0,0,0,,that you stop thinking about control structures,
Dialogue: 0,0:22:51.41,0:22:53.92,EN,,0,0,0,,and you start thinking about operations on aggregates,
Dialogue: 0,0:22:55.01,0:23:00.01,EN,,0,0,0,,and then about halfway through this course,we'll see when we talk about something called stream processing,
Dialogue: 0,0:23:00.26,0:23:02.64,EN,,0,0,0,,how that view of the world really comes into its glory.
Dialogue: 0,0:23:02.64,0:23:05.30,EN,,0,0,0,,This is just us a, sort of, cute idea.
Dialogue: 0,0:23:05.30,0:23:08.70,EN,,0,0,0,,But we'll see much more applications of that later on.
Dialogue: 0,0:23:09.36,0:23:16.84,EN,,0,0,0,,Well let me mention that there's something that's very similar to MAP that's also a useful idea, and that's--
Dialogue: 0,0:23:17.56,0:23:22.54,EN,,0,0,0,,see, MAP says I take a List, I apply something to each item,
Dialogue: 0,0:23:22.98,0:23:25.62,EN,,0,0,0,,and I return a List of the successive values.
Dialogue: 0,0:23:25.98,0:23:28.69,EN,,0,0,0,,There's another thing I might do, which is very, very similar,
Dialogue: 0,0:23:29.32,0:23:35.86,EN,,0,0,0,,which is take a List and some action you want to do and then do it to each item in the List in sequence.
Dialogue: 0,0:23:36.29,0:23:39.40,EN,,0,0,0,,Don't make a List of the values, just do this particular action,
Dialogue: 0,0:23:40.02,0:23:45.10,EN,,0,0,0,,and that's something that's very much like MAP.
Dialogue: 0,0:23:45.10,0:23:46.02,EN,,0,0,0,,It's called for-each,
Dialogue: 0,0:23:46.74,0:23:49.48,EN,,0,0,0,,and for-each takes a procedure and a List,
Dialogue: 0,0:23:49.62,0:23:53.86,EN,,0,0,0,,and what it's going to do is do something to every item in the List.
Dialogue: 0,0:23:55.16,0:23:58.53,EN,,0,0,0,,So basically what it does: it says if the List is not empty,
Dialogue: 0,0:23:59.74,0:24:01.12,EN,,0,0,0,,if the List is not null,
Dialogue: 0,0:24:01.90,0:24:06.25,EN,,0,0,0,,then what I do is, I apply my procedure to the first item in the List,
Dialogue: 0,0:24:07.68,0:24:11.66,EN,,0,0,0,,and then I do this thing to the rest of the List.
Dialogue: 0,0:24:12.44,0:24:15.25,EN,,0,0,0,,I apply for-each to the cdr of the List.
Dialogue: 0,0:24:15.88,0:24:18.73,EN,,0,0,0,,All right, so I do it to the first of the List, do it to the rest of the List,
Dialogue: 0,0:24:19.32,0:24:23.92,EN,,0,0,0,,and of course, when I call it recursively, that's going to do it to the rest of the rest of the List and so on.
Dialogue: 0,0:24:23.92,0:24:28.12,EN,,0,0,0,,And finally, when I get done, I have to just do something to say I'm done,
Dialogue: 0,0:24:28.16,0:24:32.40,EN,,0,0,0,,so we'll return the message "done." So that's very, very similar to MAP.
Dialogue: 0,0:24:32.80,0:24:35.12,EN,,0,0,0,,It's mostly different in what it returns.
Dialogue: 0,0:24:35.48,0:24:39.90,EN,,0,0,0,,And so for example, if I had some procedure that printed things on the screen,
Dialogue: 0,0:24:40.56,0:24:45.81,EN,,0,0,0,,if I wanted to print everything in the List, I could say for-each, print this List.
Dialogue: 0,0:24:46.78,0:24:51.33,EN,,0,0,0,,Or if I had a List of figures, and I wanted to draw them on the display,
Dialogue: 0,0:24:51.62,0:24:54.86,EN,,0,0,0,,I could say for-each, display on the screen this figure.
Dialogue: 0,0:24:58.18,0:24:59.32,EN,,0,0,0,,Take questions.
Dialogue: 0,0:25:00.62,0:25:04.26,EN,,0,0,0,,AUDIENCE: Does it create a new copy with something done to it,
Dialogue: 0,0:25:04.30,0:25:07.54,EN,,0,0,0,,unless you explicitly tell it to do that? Is that correct?
Dialogue: 0,0:25:07.54,0:25:09.18,EN,,0,0,0,,PROFESSOR: Right. Ah.
Dialogue: 0,0:25:09.93,0:25:10.94,EN,,0,0,0,,Yeah, that's right.
Dialogue: 0,0:25:10.94,0:25:15.14,EN,,0,0,0,,For-each does not create a List. It just sort of does something.
Dialogue: 0,0:25:15.14,0:25:17.29,EN,,0,0,0,,So if you have a bunch of things you want to do
Dialogue: 0,0:25:18.02,0:25:21.56,EN,,0,0,0,,and you're not worried about values like printing something, or drawing something on the screen,
Dialogue: 0,0:25:21.89,0:25:24.60,EN,,0,0,0,,or ringing the bell on the terminal,or for something,
Dialogue: 0,0:25:24.60,0:25:27.64,EN,,0,0,0,,you can say for-each, you know, do this for-each of those things in the List,
Dialogue: 0,0:25:28.21,0:25:32.42,EN,,0,0,0,,whereas MAP actually builds you this new collection of values that you might want to use.
Dialogue: 0,0:25:32.42,0:25:34.16,EN,,0,0,0,,It's just a subtle difference between them.
Dialogue: 0,0:25:34.16,0:25:36.30,EN,,0,0,0,,AUDIENCE: Could you write MAP using for-each,
Dialogue: 0,0:25:36.32,0:25:40.16,EN,,0,0,0,,so that you did some sort of cons or something to build the List back up?
Dialogue: 0,0:25:40.18,0:25:44.46,EN,,0,0,0,,PROFESSOR: Well, sort of. I mean, I probably could.
Dialogue: 0,0:25:44.46,0:25:49.98,EN,,0,0,0,,I can't think of how to do it right offhand, but yeah, I could arrange something.
Dialogue: 0,0:25:50.48,0:25:54.73,EN,,0,0,0,,AUDIENCE: The vital difference between MAP and for-each is one is recursive and the other is not
Dialogue: 0,0:25:54.73,0:26:00.62,EN,,0,0,0,,in the sense you defined early yesterday, I believe.
Dialogue: 0,0:26:01.24,0:26:03.86,EN,,0,0,0,,PROFESSOR: Yeah, about MAP and for-each and recursion.
Dialogue: 0,0:26:03.86,0:26:05.48,EN,,0,0,0,,Yeah, that's a good point.
Dialogue: 0,0:26:05.48,0:26:13.08,EN,,0,0,0,,For the MAP procedure I wrote, that happens to be a recursive process.
Dialogue: 0,0:26:13.82,0:26:17.06,EN,,0,0,0,,And the reason for that is that when you've done this thing to the rest of the List,
Dialogue: 0,0:26:17.08,0:26:20.96,EN,,0,0,0,,you're waiting for that value so that you can stick it on to the beginning of the List,
Dialogue: 0,0:26:21.73,0:26:24.53,EN,,0,0,0,,whereas for-each doesn't really have any values to wait for.
Dialogue: 0,0:26:24.84,0:26:26.66,EN,,0,0,0,,So that turns out to be an iterative process.
Dialogue: 0,0:26:26.66,0:26:27.72,EN,,0,0,0,,That's not fundamental.
Dialogue: 0,0:26:27.72,0:26:31.80,EN,,0,0,0,,I could have defined MAP so that it's evolved by an iterative process.
Dialogue: 0,0:26:31.82,0:26:32.82,EN,,0,0,0,,I just didn't happen to.
Dialogue: 0,0:26:34.24,0:26:42.90,EN,,0,0,0,,AUDIENCE: If you were to call for each with a List that had embedded Lists, I imagine it would work, right?
Dialogue: 0,0:26:42.90,0:26:48.10,EN,,0,0,0,,It would give you the internal elements of each of those internal Lists?
Dialogue: 0,0:26:48.70,0:26:50.40,EN,,0,0,0,,PROFESSOR: OK, the question is if I call
Dialogue: 0,0:26:50.40,0:26:52.28,EN,,0,0,0,,for-each or map, for that matter
Dialogue: 0,0:26:52.81,0:26:55.28,EN,,0,0,0,,with a List that had Lists in it
Dialogue: 0,0:26:56.69,0:27:00.60,EN,,0,0,0,,although we haven't really looked at that yet--would that work.
Dialogue: 0,0:27:01.02,0:27:06.56,EN,,0,0,0,,The answer is yes in the sense I mean work and no in the sense that you mean work,
Dialogue: 0,0:27:06.86,0:27:10.65,EN,,0,0,0,,because all that-- see if I give you a List,
Dialogue: 0,0:27:12.80,0:27:14.20,EN,,0,0,0,,where hanging off here is,
Dialogue: 0,0:27:16.06,0:27:21.46,EN,,0,0,0,,you know, is something that's not a number, maybe another List or you know, another cons or something,
Dialogue: 0,0:27:21.96,0:27:24.54,EN,,0,0,0,,for-each just says do something to each item in this List.
Dialogue: 0,0:27:24.54,0:27:26.96,EN,,0,0,0,,It goes down successively looking at the cdrs.
Dialogue: 0,0:27:26.96,0:27:27.20,EN,,0,0,0,,AUDIENCE: OK.
Dialogue: 0,0:27:27.20,0:27:31.06,EN,,0,0,0,,PROFESSOR: And as far as it's concerned, the first item in this List is whatever is hanging off here.
Dialogue: 0,0:27:31.06,0:27:31.65,EN,,0,0,0,,AUDIENCE: Mhm.
Dialogue: 0,0:27:31.65,0:27:33.94,EN,,0,0,0,,PROFESSOR: That might or might not be the right thing.
Dialogue: 0,0:27:33.94,0:27:35.57,EN,,0,0,0,,AUDIENCE: So it wouldn't go down into the--
Dialogue: 0,0:27:35.57,0:27:36.91,EN,,0,0,0,,PROFESSOR: Absolutely not.
Dialogue: 0,0:27:36.91,0:27:38.51,EN,,0,0,0,,I could certainly write something else.
Dialogue: 0,0:27:38.51,0:27:42.97,EN,,0,0,0,,There's another, what you're looking for is a common pattern of usage called tree recursion,
Dialogue: 0,0:27:43.01,0:27:47.94,EN,,0,0,0,,where you take a List, and you actually go all the way down to the what's called the leaves of the tree.
Dialogue: 0,0:27:47.94,0:27:51.05,EN,,0,0,0,,And you could write such a thing, but that's not for-each and it's not MAP.
Dialogue: 0,0:27:52.42,0:27:55.05,EN,,0,0,0,,Remember, these things are really being very simple minded.
Dialogue: 0,0:27:55.77,0:27:56.89,EN,,0,0,0,,OK, no more questions?
Dialogue: 0,0:27:57.68,0:27:58.57,EN,,0,0,0,,All right, let's break.
Dialogue: 0,0:27:59.11,0:28:10.99,EN,,0,0,0,,[JESU, JOY OF MAN'S DESIRING]
Dialogue: 0,0:28:11.46,0:28:14.29,Declare,,0,0,0,,{\an2\fad(500,500)}The Structure And Interpretation of Computer Programs
Dialogue: 0,0:28:14.32,0:28:17.52,Declare,,0,0,0,,{\an2\fad(500,500)}By: Prof. Harold Abelson && Gerald Jay Sussman
Dialogue: 0,0:28:27.38,0:28:34.22,Declare,,0,0,0,,{\an2\fad(500,500)}The Structure And Interpretation of Computer Programs
Dialogue: 0,0:28:34.86,0:28:38.58,Declare,,0,0,0,,{\an2\fad(500,500)}Henderson Escher Example
Dialogue: 0,0:28:41.94,0:28:48.65,EN,,0,0,0,,PROFESSOR: What I'd like to do now is spend the rest of this time talking about one example,
Dialogue: 0,0:28:50.04,0:28:53.92,EN,,0,0,0,,and this example, I think, pretty much summarizes everything that we've done up until now:
Dialogue: 0,0:28:54.74,0:28:56.29,EN,,0,0,0,,all right, and that's List structure
Dialogue: 0,0:28:57.17,0:28:59.48,EN,,0,0,0,,and issues of abstraction,
Dialogue: 0,0:28:59.54,0:29:00.82,EN,,0,0,0,,and representation
Dialogue: 0,0:29:01.60,0:29:04.60,EN,,0,0,0,,and representation and capturing commonality with higher order procedures,
Dialogue: 0,0:29:04.60,0:29:09.80,EN,,0,0,0,,and also is going to introduce something we haven't really talked about a lot yet-- what I said is the major third theme in this course:
Dialogue: 0,0:29:09.85,0:29:13.46,EN,,0,0,0,,what I said is the major third theme in this course:
Dialogue: 0,0:29:13.96,0:29:15.53,EN,,0,0,0,,meta-linguistic abstraction,
Dialogue: 0,0:29:15.54,0:29:21.90,EN,,0,0,0,,which is the idea that one of the ways of tackling complexity in engineering design
Dialogue: 0,0:29:22.86,0:29:25.80,EN,,0,0,0,,is to build a suitable powerful language.
Dialogue: 0,0:29:28.17,0:29:34.74,EN,,0,0,0,,You might recall what I said was pretty much the very most important thing that we're going to tell you in this course is that
Dialogue: 0,0:29:34.74,0:29:41.17,EN,,0,0,0,,when you think about a language, you think about it in terms of what are the primitives;
Dialogue: 0,0:29:42.98,0:29:46.69,EN,,0,0,0,,what are the means of combination--
Dialogue: 0,0:29:49.72,0:29:52.80,EN,,0,0,0,,right, what are the things that allow you to build bigger things;
Dialogue: 0,0:29:53.61,0:29:55.24,EN,,0,0,0,,and then what are the means of abstraction.
Dialogue: 0,0:30:00.97,0:30:05.16,EN,,0,0,0,,How do you take those bigger things that you've built
Dialogue: 0,0:30:05.56,0:30:07.97,EN,,0,0,0,,put black boxes around them
Dialogue: 0,0:30:08.45,0:30:11.71,EN,,0,0,0,,and use them as elements in making something even more complicated?
Dialogue: 0,0:30:13.53,0:30:18.72,EN,,0,0,0,,Now the particular language I'm going to talk about is an example
Dialogue: 0,0:30:18.73,0:30:22.70,EN,,0,0,0,,that was made up by a friend of ours called Peter Henderson.
Dialogue: 0,0:30:28.24,0:30:31.74,EN,,0,0,0,,Peter Henderson is at the University of Stirling in Scotland.
Dialogue: 0,0:30:32.78,0:30:40.98,EN,,0,0,0,,And what this language is about is making figures that sort of look like this.
Dialogue: 0,0:30:41.86,0:30:46.66,EN,,0,0,0,,This is this is a woodcut by Escher called "Square Limit."
Dialogue: 0,0:30:49.33,0:30:57.94,EN,,0,0,0,,You, sort of, see it has this complicated, kind of, recursive, sort of, recursive kind of figure,
Dialogue: 0,0:30:58.84,0:31:01.46,EN,,0,0,0,,where there's this fish pattern in the middle and things sort of
Dialogue: 0,0:31:01.70,0:31:04.56,EN,,0,0,0,,bleed out smaller and smaller in self similar ways.
Dialogue: 0,0:31:08.49,0:31:12.80,EN,,0,0,0,,Anyway, Peter Henderson's language was for describing figures that look like that
Dialogue: 0,0:31:13.37,0:31:18.28,EN,,0,0,0,,and designing new ones that look like that and drawing them on a display screen.
Dialogue: 0,0:31:20.24,0:31:27.48,EN,,0,0,0,,There's another theme that we'll see illustrated by this example,
Dialogue: 0,0:31:28.09,0:31:32.02,EN,,0,0,0,,and that's the issue of what Gerry and I have already mentioned a lot:
Dialogue: 0,0:31:32.02,0:31:36.17,EN,,0,0,0,,that there's no real difference, in some sense, between procedures and data.
Dialogue: 0,0:31:37.26,0:31:42.40,EN,,0,0,0,,And anyway I hope by the end of this morning, if you're not already,
Dialogue: 0,0:31:42.58,0:31:47.60,EN,,0,0,0,,you will be completely confused about what the difference between procedures and data are,
Dialogue: 0,0:31:47.96,0:31:49.58,EN,,0,0,0,,if you're not confused about that already.
Dialogue: 0,0:31:50.80,0:31:55.28,EN,,0,0,0,,Well in any case, let's start describing Peter's language.
Dialogue: 0,0:31:55.28,0:31:57.26,EN,,0,0,0,,I should start by telling you what the primitives are.
Dialogue: 0,0:31:58.29,0:32:00.92,EN,,0,0,0,,This language is very simple because there's only one primitive.
Dialogue: 0,0:32:03.33,0:32:06.30,EN,,0,0,0,,A primitive is not quite what you think it is.
Dialogue: 0,0:32:07.08,0:32:09.18,EN,,0,0,0,,There's only one primitive called a picture,
Dialogue: 0,0:32:09.70,0:32:12.11,EN,,0,0,0,,and a picture is not quite what you think it is.
Dialogue: 0,0:32:12.11,0:32:14.17,EN,,0,0,0,,Here's an example.
Dialogue: 0,0:32:14.17,0:32:15.17,EN,,0,0,0,,This is a picture of George.
Dialogue: 0,0:32:19.01,0:32:20.37,EN,,0,0,0,,The idea is that
Dialogue: 0,0:32:22.33,0:32:24.57,EN,,0,0,0,,a picture in this language is going to be something
Dialogue: 0,0:32:24.89,0:32:31.46,EN,,0,0,0,,that draws a figure scaled to fit a rectangle that you specify.
Dialogue: 0,0:32:33.00,0:32:34.42,EN,,0,0,0,,So here you see emphasis line
Dialogue: 0,0:32:34.42,0:32:37.70,EN,,0,0,0,,is outline of a rectangle, that's not really part of the picture,
Dialogue: 0,0:32:40.49,0:32:47.17,EN,,0,0,0,,but the picture-- you'll give it a rectangle, and it will draw this figure scaled to fit the rectangle.
Dialogue: 0,0:32:47.17,0:32:52.16,EN,,0,0,0,,So for example, there's George, and here, this is also George.
Dialogue: 0,0:32:53.21,0:32:56.65,EN,,0,0,0,,It's the same picture, right, just scaled to fit a different rectangle.
Dialogue: 0,0:32:57.40,0:32:59.28,EN,,0,0,0,,Here's George as a fat kid.
Dialogue: 0,0:33:00.01,0:33:03.44,EN,,0,0,0,,That's the same George.
Dialogue: 0,0:33:03.81,0:33:05.14,EN,,0,0,0,,It's all the same figure.
Dialogue: 0,0:33:05.14,0:33:09.57,EN,,0,0,0,,All of these three things are the same picture in this language.
Dialogue: 0,0:33:09.58,0:33:13.04,EN,,0,0,0,,I'm just giving it different rectangles to scale itself in.
Dialogue: 0,0:33:16.08,0:33:20.65,EN,,0,0,0,,OK, those are the primitives. That is the primitive.
Dialogue: 0,0:33:21.44,0:33:25.25,EN,,0,0,0,,Now let's start talking about the means of combination and the operations.
Dialogue: 0,0:33:25.90,0:33:30.17,EN,,0,0,0,,There is, for example, an operation called Rotate.
Dialogue: 0,0:33:31.09,0:33:33.66,EN,,0,0,0,,And what Rotate does is, if I have a picture,
Dialogue: 0,0:33:35.37,0:33:39.93,EN,,0,0,0,,say a picture that draws an "A" in some rectangle that I give it,
Dialogue: 0,0:33:41.84,0:33:45.73,EN,,0,0,0,,the Rotate of that--say the Rotate by 90 degrees would,
Dialogue: 0,0:33:47.02,0:33:50.65,EN,,0,0,0,,if I give it a rectangle, draw the same image,
Dialogue: 0,0:33:50.65,0:33:53.88,EN,,0,0,0,,but again, scaled to fit that rectangle.
Dialogue: 0,0:33:56.11,0:33:58.34,EN,,0,0,0,,So that's Rotate by 90 degrees.
Dialogue: 0,0:33:58.34,0:34:03.20,EN,,0,0,0,,There's another operation called Flip that can flip something, either horizontally or vertically.
Dialogue: 0,0:34:04.77,0:34:06.00,EN,,0,0,0,,All right, so those are, sort of, operations,
Dialogue: 0,0:34:06.01,0:34:10.40,EN,,0,0,0,,or you can think of those as means of combination of one element.
Dialogue: 0,0:34:10.89,0:34:12.42,EN,,0,0,0,,I can put things together.
Dialogue: 0,0:34:13.44,0:34:15.54,EN,,0,0,0,,There's a means of combination called Beside,
Dialogue: 0,0:34:16.46,0:34:24.78,EN,,0,0,0,,and what Beside does: it'll take two pictures, let's say A and B--
Dialogue: 0,0:34:29.02,0:34:33.25,EN,,0,0,0,,and by picture I mean something that's going to draw an image in a specified rectangle--
Dialogue: 0,0:34:34.05,0:34:36.51,EN,,0,0,0,,and what Beside will do--
Dialogue: 0,0:34:37.85,0:34:44.08,EN,,0,0,0,,I have to say, Beside of A and B, the side of two pictures and some number, s.
Dialogue: 0,0:34:45.34,0:34:48.08,EN,,0,0,0,,And s will be a number between zero and one.
Dialogue: 0,0:34:50.51,0:34:52.57,EN,,0,0,0,,And Beside will draw a picture that looks like this.
Dialogue: 0,0:34:52.57,0:34:56.71,EN,,0,0,0,,It will take the rectangle you give it and scale its base by s.
Dialogue: 0,0:34:56.71,0:34:58.71,EN,,0,0,0,,Say s is 0.5.
Dialogue: 0,0:35:00.18,0:35:07.17,EN,,0,0,0,,And then over here it will draw-- it'll put the first picture, and over here it'll put the second picture.
Dialogue: 0,0:35:07.81,0:35:12.65,EN,,0,0,0,,and over here it'll put the second picture.
Dialogue: 0,0:35:13.82,0:35:16.44,EN,,0,0,0,,Or for instance if I gave it a different value of s,
Dialogue: 0,0:35:16.81,0:35:23.02,EN,,0,0,0,,Or for instance if I gave it a different value of s, if I said Beside with a 0.25,
Dialogue: 0,0:35:25.94,0:35:29.09,EN,,0,0,0,,it would do the same thing, except the A would be much skinnier.
Dialogue: 0,0:35:34.05,0:35:36.28,EN,,0,0,0,,So it would draw something like that.
Dialogue: 0,0:35:37.82,0:35:40.29,EN,,0,0,0,,So there's a means of combination Beside,
Dialogue: 0,0:35:40.68,0:35:46.05,EN,,0,0,0,,and similarly there's an Above, which does the same thing except it puts them vertically instead of horizontally.
Dialogue: 0,0:35:47.84,0:35:48.89,EN,,0,0,0,,Well let's look at that.
Dialogue: 0,0:35:50.74,0:35:56.00,EN,,0,0,0,,All right, there's George and his kid brother,
Dialogue: 0,0:35:56.72,0:36:07.05,EN,,0,0,0,,which is, right, constructed by taking George and putting him Beside
Dialogue: 0,0:36:10.36,0:36:14.42,EN,,0,0,0,,The Above, taking the empty picture, and there's a thing called the empty picture,
Dialogue: 0,0:36:14.52,0:36:16.14,EN,,0,0,0,,which does the obvious thing--
Dialogue: 0,0:36:16.14,0:36:19.14,EN,,0,0,0,,putting the empty picture above a copy of George,
Dialogue: 0,0:36:19.14,0:36:21.14,EN,,0,0,0,,and then putting that whole thing Beside George.
Dialogue: 0,0:36:28.96,0:36:30.34,EN,,0,0,0,,Here's something called P which is,
Dialogue: 0,0:36:31.10,0:36:39.04,EN,,0,0,0,,which is, again, George Beside Flipping George,
Dialogue: 0,0:36:40.53,0:36:42.08,EN,,0,0,0,,I think, horizontally in this case,
Dialogue: 0,0:36:42.37,0:36:44.80,EN,,0,0,0,,Rotating the whole result 180 degrees
Dialogue: 0,0:36:45.80,0:36:50.82,EN,,0,0,0,,putting them Beside one another with the basic rectangle divided at 0.5,
Dialogue: 0,0:36:52.56,0:36:53.90,EN,,0,0,0,,right, and I can call that P.
Dialogue: 0,0:36:55.90,0:36:57.88,EN,,0,0,0,,And then I can take P,
Dialogue: 0,0:36:59.21,0:37:04.96,EN,,0,0,0,,And then I can take P, and put it above the Flipped copy of itself, and I can call that Q.
Dialogue: 0,0:37:09.20,0:37:13.26,EN,,0,0,0,,Notice how rapidly that we've built up complexity,
Dialogue: 0,0:37:14.36,0:37:21.05,EN,,0,0,0,,just in, you know, 15 seconds, you've gotten from George to that thing Q. Why is that?
Dialogue: 0,0:37:22.05,0:37:24.55,EN,,0,0,0,,How are how we able to do that so fast?
Dialogue: 0,0:37:25.85,0:37:28.02,EN,,0,0,0,,The answer is the closure property.
Dialogue: 0,0:37:28.69,0:37:32.98,EN,,0,0,0,,See, it's the fact that when I take a picture and put it Beside another picture,
Dialogue: 0,0:37:34.30,0:37:35.29,EN,,0,0,0,,that's then, again, a picture
Dialogue: 0,0:37:35.33,0:37:37.78,EN,,0,0,0,,that I can go and Rotate and Flip or put Above something else.
Dialogue: 0,0:37:39.17,0:37:40.88,EN,,0,0,0,,Right, and when I take that element P,
Dialogue: 0,0:37:40.89,0:37:44.88,EN,,0,0,0,,which is the Beside or the Flip or the Rotate of something, that's, again, a picture.
Dialogue: 0,0:37:45.22,0:37:50.20,EN,,0,0,0,,Right, the world of pictures is closed under those means of combination.
Dialogue: 0,0:37:50.77,0:37:52.24,EN,,0,0,0,,So whenever I have something,
Dialogue: 0,0:37:52.48,0:37:55.17,EN,,0,0,0,,I can turn right around and use that as an element in something else.
Dialogue: 0,0:37:56.33,0:37:58.52,EN,,0,0,0,,So maybe better than List and segments,
Dialogue: 0,0:37:58.54,0:38:03.28,EN,,0,0,0,,that just gives you an image for how fast you can build up complexity, because operations are closed.
Dialogue: 0,0:38:07.48,0:38:12.02,EN,,0,0,0,,OK, well before we go on with building more things,
Dialogue: 0,0:38:12.04,0:38:14.77,EN,,0,0,0,,let's talk about how this language is actually implemented.
Dialogue: 0,0:38:16.91,0:38:21.50,EN,,0,0,0,,The basic element that sits under the table here
Dialogue: 0,0:38:21.93,0:38:24.52,EN,,0,0,0,,is a thing called a rectangle,
Dialogue: 0,0:38:26.09,0:38:28.28,EN,,0,0,0,,and what a rectangle is going to be,
Dialogue: 0,0:38:28.28,0:38:33.68,EN,,0,0,0,,it's a thing that specified by an origin
Dialogue: 0,0:38:36.45,0:38:40.18,EN,,0,0,0,,that's going to be some vector that says where the rectangle starts.
Dialogue: 0,0:38:40.18,0:38:42.29,EN,,0,0,0,,And then there's going to be some other vector
Dialogue: 0,0:38:43.66,0:38:46.33,EN,,0,0,0,,that I'm going to call the horizontal part of the rectangle,
Dialogue: 0,0:38:55.76,0:38:59.25,EN,,0,0,0,,and another vector called the vertical part of the rectangle.
Dialogue: 0,0:39:00.49,0:39:02.68,EN,,0,0,0,,And those three pieces are the elements:
Dialogue: 0,0:39:02.68,0:39:04.51,EN,,0,0,0,,where the lower vertex is,
Dialogue: 0,0:39:04.93,0:39:09.97,EN,,0,0,0,,how you get to the next vertex over here, and how you get to the vertex over there.
Dialogue: 0,0:39:09.97,0:39:12.37,EN,,0,0,0,,The three vectors specify a rectangle.
Dialogue: 0,0:39:16.00,0:39:18.93,EN,,0,0,0,,Now to actually build rectangles, what I'll assume is
Dialogue: 0,0:39:19.77,0:39:22.06,EN,,0,0,0,,that we have a constructor called "make rectangle,"
Dialogue: 0,0:39:23.01,0:39:24.26,EN,,0,0,0,,or "make-rect,"
Dialogue: 0,0:39:27.56,0:39:35.17,EN,,0,0,0,,and selectors for horiz and vert and origin
Dialogue: 0,0:39:37.58,0:39:39.65,EN,,0,0,0,,that get out the pieces of that rectangle.
Dialogue: 0,0:39:39.65,0:39:42.54,EN,,0,0,0,,And well, you know a lot of ways you can do this now.
Dialogue: 0,0:39:42.54,0:39:47.62,EN,,0,0,0,,You can do it by using pairs in some way or other standard List or not.
Dialogue: 0,0:39:47.62,0:39:51.40,EN,,0,0,0,,But in any case, the implementation of these things, that's George's problem.
Dialogue: 0,0:39:51.40,0:39:53.17,EN,,0,0,0,,It's just a data representation problem.
Dialogue: 0,0:39:53.17,0:39:55.47,EN,,0,0,0,,So let's assume we have these rectangles to work with.
Dialogue: 0,0:39:59.05,0:40:05.08,EN,,0,0,0,,OK. Now the idea of this, remember what's got to happen.
Dialogue: 0,0:40:05.08,0:40:08.22,EN,,0,0,0,,Somehow we have to worry about taking the figure
Dialogue: 0,0:40:09.33,0:40:12.97,EN,,0,0,0,,and scaling it to fit some rectangle that you give it,
Dialogue: 0,0:40:13.60,0:40:16.60,EN,,0,0,0,,that's the basic thing you have to arrange,
Dialogue: 0,0:40:16.60,0:40:18.60,EN,,0,0,0,,that these pictures can do.
Dialogue: 0,0:40:22.22,0:40:23.65,EN,,0,0,0,,How do we think about that?
Dialogue: 0,0:40:23.65,0:40:27.08,EN,,0,0,0,,Well, one way to think about that is that any time I give you a rectangle,
Dialogue: 0,0:40:35.68,0:40:38.68,EN,,0,0,0,,Any time I gave you a rectangle, that defines,
Dialogue: 0,0:40:39.25,0:40:45.77,EN,,0,0,0,,that defines,in some sense, a transformation from the standard square into that rectangle.
Dialogue: 0,0:40:45.77,0:40:46.54,EN,,0,0,0,,Let me say what I mean.
Dialogue: 0,0:40:46.54,0:40:48.53,EN,,0,0,0,,By the standard square, I'll mean something,
Dialogue: 0,0:40:49.04,0:40:59.04,EN,,0,0,0,,which is a square whose coordinates are 0,0, and 1,0, and 0,1 and 1,1.
Dialogue: 0,0:41:01.40,0:41:05.72,EN,,0,0,0,,And there's some sort of the obvious scaling transformation,
Dialogue: 0,0:41:06.12,0:41:10.22,EN,,0,0,0,,which maps this to that and this to that,
Dialogue: 0,0:41:10.24,0:41:12.08,EN,,0,0,0,,and sort of, stretches everything uniformly.
Dialogue: 0,0:41:12.17,0:41:18.25,EN,,0,0,0,,So we take a line segment like this
Dialogue: 0,0:41:19.73,0:41:24.20,EN,,0,0,0,,and end up mapping it to a line segment like that,
Dialogue: 0,0:41:26.20,0:41:32.68,EN,,0,0,0,,so some point (x,y) goes to some other point up there.
Dialogue: 0,0:41:32.68,0:41:39.37,EN,,0,0,0,,And although it's not important, with a little vector algebra, you could write that formula.
Dialogue: 0,0:41:39.37,0:41:43.18,EN,,0,0,0,,The thing that (x,y) goes to, the point that (x,y) goes to is
Dialogue: 0,0:41:43.58,0:41:50.74,EN,,0,0,0,,gotten by taking the origin of the rectangle and then adding that as a vector to--
Dialogue: 0,0:41:51.16,0:41:55.48,EN,,0,0,0,,well, take x, the x coordinate, which is something between zero and one,
Dialogue: 0,0:41:55.98,0:42:01.84,EN,,0,0,0,,multiply that by the horizontal vector of the rectangle;
Dialogue: 0,0:42:07.62,0:42:11.00,EN,,0,0,0,,and take the y coordinate, which is also something between zero and one
Dialogue: 0,0:42:11.38,0:42:16.28,EN,,0,0,0,,and multiply that by the vertical vector of the rectangle.
Dialogue: 0,0:42:16.74,0:42:19.31,EN,,0,0,0,,That's just a little linear algebra.
Dialogue: 0,0:42:19.31,0:42:23.48,EN,,0,0,0,,Anyway, that's the formula, which is the right obvious transformation
Dialogue: 0,0:42:23.69,0:42:28.18,EN,,0,0,0,,that takes things into the unit square, into the interior of that rectangle.
Dialogue: 0,0:42:31.34,0:42:34.02,EN,,0,0,0,,OK well, let's actually look at that as a procedure.
Dialogue: 0,0:42:35.16,0:42:36.29,EN,,0,0,0,,So what we want is
Dialogue: 0,0:42:37.80,0:42:40.82,EN,,0,0,0,,the thing which tells us that particular transformation
Dialogue: 0,0:42:41.01,0:42:42.52,EN,,0,0,0,,that a rectangle defines.
Dialogue: 0,0:42:43.80,0:42:45.22,EN,,0,0,0,,So here's the procedure.
Dialogue: 0,0:42:45.22,0:42:47.22,EN,,0,0,0,,I'll call it coordinate-map.
Dialogue: 0,0:42:47.77,0:42:52.00,EN,,0,0,0,,Coordinate-map is the thing that takes as its argument a rectangle
Dialogue: 0,0:42:53.60,0:42:57.85,EN,,0,0,0,,and returns for you a procedure on points.
Dialogue: 0,0:43:00.45,0:43:06.82,EN,,0,0,0,,Right, so for each rectangle you get a way of transforming a point (x,y) into that rectangle.
Dialogue: 0,0:43:06.82,0:43:08.02,EN,,0,0,0,,And how do you get it?
Dialogue: 0,0:43:08.02,0:43:10.92,EN,,0,0,0,,Well I just-- writing in Lisp what I wrote there on the blackboard--
Dialogue: 0,0:43:10.92,0:43:16.01,EN,,0,0,0,,I add to the origin of the rectangle
Dialogue: 0,0:43:20.22,0:43:25.02,EN,,0,0,0,,the result of adding-- I take the horizontal part of the rectangle;
Dialogue: 0,0:43:25.02,0:43:27.68,EN,,0,0,0,,I scale that by the x coordinate of the point.
Dialogue: 0,0:43:29.65,0:43:32.62,EN,,0,0,0,,I take the vertical vector of the rectangle.
Dialogue: 0,0:43:33.51,0:43:37.14,EN,,0,0,0,,I scale that by the y coordinate of the point,
Dialogue: 0,0:43:37.14,0:43:39.14,EN,,0,0,0,,and then add all those three things up.
Dialogue: 0,0:43:40.13,0:43:41.34,EN,,0,0,0,,That's the procedure.
Dialogue: 0,0:43:41.34,0:43:44.54,EN,,0,0,0,,That is the procedure that I'm going to apply to a point.
Dialogue: 0,0:43:46.54,0:43:52.17,EN,,0,0,0,,And this whole thing is generated for each rectangle.
Dialogue: 0,0:43:52.17,0:43:57.25,EN,,0,0,0,,So any rectangle defines a Coordinate-MAP, which is a procedure on points.
Dialogue: 0,0:44:06.66,0:44:10.42,EN,,0,0,0,,All right, so for example, George here,
Dialogue: 0,0:44:11.36,0:44:16.34,EN,,0,0,0,,my original George, might have been something that I specified by segments in the unit square,
Dialogue: 0,0:44:19.50,0:44:21.96,EN,,0,0,0,,and then for each rectangle I give this thing,
Dialogue: 0,0:44:24.14,0:44:28.17,EN,,0,0,0,,I'm going to draw those segments inside that rectangle.
Dialogue: 0,0:44:28.17,0:44:29.88,EN,,0,0,0,,How actually do I do that?
Dialogue: 0,0:44:30.68,0:44:36.94,EN,,0,0,0,,Well I take each segment in my original reference George that was specified,
Dialogue: 0,0:44:38.64,0:44:40.58,EN,,0,0,0,,and to each of the end points of those segments,
Dialogue: 0,0:44:40.88,0:44:44.45,EN,,0,0,0,,I applied the COORDINATE-MAP of the particular rectangle I want to draw it in.
Dialogue: 0,0:44:44.45,0:44:46.06,EN,,0,0,0,,So for example, this lower rectangle,
Dialogue: 0,0:44:46.66,0:44:50.88,EN,,0,0,0,,this George as a fat kid rectangle, has its COORDINATE-MAP.
Dialogue: 0,0:44:51.25,0:44:53.69,EN,,0,0,0,,And if I want to draw this image,
Dialogue: 0,0:44:55.38,0:44:57.92,EN,,0,0,0,,And if I want to draw this image, what I do is for each segment here, say for this segment,
Dialogue: 0,0:44:59.29,0:45:05.34,EN,,0,0,0,,I transformed that point by the coordinate MAP, transform that point by the coordinate MAP.
Dialogue: 0,0:45:05.34,0:45:07.09,EN,,0,0,0,,That will give me this point and that point
Dialogue: 0,0:45:07.38,0:45:08.94,EN,,0,0,0,,and draw the segment between them.
Dialogue: 0,0:45:09.71,0:45:11.52,EN,,0,0,0,,Right, that's the idea.
Dialogue: 0,0:45:12.66,0:45:14.78,EN,,0,0,0,,Right, and if I give it a different rectangle like this one,
Dialogue: 0,0:45:14.80,0:45:15.76,EN,,0,0,0,,that's a different coordinate-MAP,
Dialogue: 0,0:45:15.79,0:45:17.84,EN,,0,0,0,,so I get a different image of those line segments.
Dialogue: 0,0:45:19.28,0:45:22.14,EN,,0,0,0,,Well how do we actually get a picture to start with?
Dialogue: 0,0:45:22.14,0:45:26.52,EN,,0,0,0,,I can build a picture to start with out of a List of line segments initially.
Dialogue: 0,0:45:27.61,0:45:32.20,EN,,0,0,0,,Here's a procedure that builds what I'll call a primitive picture,
Dialogue: 0,0:45:33.48,0:45:37.17,EN,,0,0,0,,meaning one I, sort of, got that didn't come out of Beside or Rotate or something.
Dialogue: 0,0:45:37.52,0:45:39.60,EN,,0,0,0,,It starts with a List of line segments,
Dialogue: 0,0:45:42.94,0:45:44.04,EN,,0,0,0,,And now it does what I said.
Dialogue: 0,0:45:44.04,0:45:45.58,EN,,0,0,0,,What's a picture have to be?
Dialogue: 0,0:45:45.58,0:45:49.44,EN,,0,0,0,,First of all it's a procedure that's defined on rectangles.
Dialogue: 0,0:45:51.70,0:45:53.00,EN,,0,0,0,,What does it do?
Dialogue: 0,0:45:53.00,0:45:56.56,EN,,0,0,0,,It says for each-- this is going to be a List of line segments--
Dialogue: 0,0:45:57.66,0:46:03.38,EN,,0,0,0,,for each segment, for each s, which is a segment in this List of segments,
Dialogue: 0,0:46:05.89,0:46:07.30,EN,,0,0,0,,well it draws a line.
Dialogue: 0,0:46:07.30,0:46:08.82,EN,,0,0,0,,What line does it draw?
Dialogue: 0,0:46:10.60,0:46:12.84,EN,,0,0,0,,It gets the start point of that segment,
Dialogue: 0,0:46:15.22,0:46:17.94,EN,,0,0,0,,transforms that by the coordinate MAP of the rectangle.
Dialogue: 0,0:46:19.54,0:46:21.76,EN,,0,0,0,,That's the first new point it wants to do.
Dialogue: 0,0:46:21.76,0:46:26.32,EN,,0,0,0,,Then it takes the endpoint of the segment, transforms that by the coordinate MAP of the rectangle,
Dialogue: 0,0:46:26.69,0:46:27.92,EN,,0,0,0,,and then draws a line between.
Dialogue: 0,0:46:27.92,0:46:30.84,EN,,0,0,0,,Let's assume drawline is some primitive that's built into the system
Dialogue: 0,0:46:31.09,0:46:33.22,EN,,0,0,0,,that actually draws a line on the display.
Dialogue: 0,0:46:33.96,0:46:37.10,EN,,0,0,0,,All right, so it transforms the endpoints by the coordinate MAP of the rectangle,
Dialogue: 0,0:46:37.13,0:46:38.20,EN,,0,0,0,,draws a line between them,
Dialogue: 0,0:46:39.61,0:46:44.12,EN,,0,0,0,,does that for each s in this List of segments.
Dialogue: 0,0:46:45.96,0:46:51.40,EN,,0,0,0,,And now remember again, a picture is a procedure that takes a rectangle as argument.
Dialogue: 0,0:46:51.40,0:46:55.65,EN,,0,0,0,,So when you hand it a rectangle, this is what it does: draws those lines.
Dialogue: 0,0:46:57.17,0:47:01.10,EN,,0,0,0,,All right, so there's-- how would I actually use this thing?
Dialogue: 0,0:47:01.22,0:47:04.08,EN,,0,0,0,,Let's make it a little bit more concrete.
Dialogue: 0,0:47:05.60,0:47:24.22,EN,,0,0,0,,Right, I would say for instance, define R to be make-rectangle of some stuff,
Dialogue: 0,0:47:24.50,0:47:28.66,EN,,0,0,0,,and I'd have to specify some vectors here using make-vector.
Dialogue: 0,0:47:29.84,0:47:46.18,EN,,0,0,0,,And then I could say, define say, G to be make-picture, and then some stuff.
Dialogue: 0,0:47:46.68,0:47:55.28,EN,,0,0,0,,And what I'd have to specify here is a List of line segments, right, using make segment.
Dialogue: 0,0:47:55.28,0:47:58.70,EN,,0,0,0,,Make-segment might be made out of vectors, and vectors might be made out of points.
Dialogue: 0,0:47:59.50,0:48:04.60,EN,,0,0,0,,And then if I actually wanted to see the image of G inside a rectangle,
Dialogue: 0,0:48:04.65,0:48:11.72,EN,,0,0,0,,well a picture is a procedure that takes a rectangle as argument.
Dialogue: 0,0:48:12.06,0:48:16.37,EN,,0,0,0,,So if I then called G with an input of R,
Dialogue: 0,0:48:17.96,0:48:23.25,EN,,0,0,0,,that would cause whatever image G is worrying about to be drawn inside the rectangle R.
Dialogue: 0,0:48:23.62,0:48:25.62,EN,,0,0,0,,Right, so that's how you'd use that.
Dialogue: 0,0:48:26.86,0:48:36.29,EN,,0,0,0,,[JESU, JOY OF MAN'S DESIRING]
Dialogue: 0,0:48:36.29,0:48:39.78,Declare,,0,0,0,,{\an2\fad(500,500)}The Structure And Interpretation of Computer Programs
Dialogue: 0,0:48:39.82,0:48:43.54,Declare,,0,0,0,,{\an2\fad(500,500)}By: Prof. Harold Abelson && Gerald Jay Sussman
Dialogue: 0,0:48:51.28,0:48:55.45,Declare,,0,0,0,,{\an2\fad(500,500)}The Structure And Interpretation of Computer Programs
Dialogue: 0,0:48:55.50,0:48:58.73,Declare,,0,0,0,,{\an2\fad(500,500)}By: Prof. Harold Abelson && Gerald Jay Sussman
Dialogue: 0,0:48:59.34,0:49:03.02,Declare,,0,0,0,,{\an2\fad(500,500)}Henderson Escher Example
Dialogue: 0,0:49:07.72,0:49:12.48,EN,,0,0,0,,PROFESSOR: Well why is it that I say this example is nice?
Dialogue: 0,0:49:12.48,0:49:13.74,EN,,0,0,0,,You probably don't think it's nice.
Dialogue: 0,0:49:13.74,0:49:15.42,EN,,0,0,0,,You probably think it's more weird than nice.
Dialogue: 0,0:49:15.42,0:49:20.92,EN,,0,0,0,,Right, representing these pictures as procedures, which do complicated things with rectangles.
Dialogue: 0,0:49:20.92,0:49:22.72,EN,,0,0,0,,So why is it nice?
Dialogue: 0,0:49:25.36,0:49:26.69,EN,,0,0,0,,The reason it's nice
Dialogue: 0,0:49:27.22,0:49:30.40,EN,,0,0,0,,is that once you've implemented the primitives in this way,
Dialogue: 0,0:49:30.97,0:49:35.20,EN,,0,0,0,,the means of combination just fall out by implementing procedures.
Dialogue: 0,0:49:35.98,0:49:37.48,EN,,0,0,0,,Let me show you what I mean.
Dialogue: 0,0:49:37.48,0:49:39.02,EN,,0,0,0,,Suppose we want to implement Beside.
Dialogue: 0,0:49:41.56,0:49:47.36,EN,,0,0,0,,So I'd like to-- suppose I've got a picture. Let's call it P1.
Dialogue: 0,0:49:47.36,0:49:50.62,EN,,0,0,0,,P1 is going to be-- and now remember what a picture really is.
Dialogue: 0,0:49:50.62,0:49:54.82,EN,,0,0,0,,It's a thing that if you hand it some rectangle,
Dialogue: 0,0:49:56.52,0:50:01.46,EN,,0,0,0,,it will cause an image to be drawn in whatever rectangle you hand it.
Dialogue: 0,0:50:03.46,0:50:09.26,EN,,0,0,0,,And suppose P2 two is some other picture, and you hand that a rectangle.
Dialogue: 0,0:50:09.74,0:50:12.44,EN,,0,0,0,,And whatever rectangle you hand it, it draws some picture.
Dialogue: 0,0:50:14.84,0:50:26.60,EN,,0,0,0,,And now if I'd like to implement Beside of P1 and P2 with a scale factor A,
Dialogue: 0,0:50:27.04,0:50:28.38,EN,,0,0,0,,well what does that have to be?
Dialogue: 0,0:50:28.38,0:50:29.34,EN,,0,0,0,,That's gotta be a picture.
Dialogue: 0,0:50:29.92,0:50:33.88,EN,,0,0,0,,It's gotta be a thing that you handed a rectangle and draw something in that rectangle.
Dialogue: 0,0:50:34.77,0:50:37.18,EN,,0,0,0,,So if hand Beside this rectangle--
Dialogue: 0,0:50:38.58,0:50:40.12,EN,,0,0,0,,let's hand it a rectangle.
Dialogue: 0,0:50:41.50,0:50:42.74,EN,,0,0,0,,Well what's it going to do?
Dialogue: 0,0:50:42.76,0:50:46.36,EN,,0,0,0,,It's going to take this rectangle and split it into two
Dialogue: 0,0:50:49.29,0:50:51.57,EN,,0,0,0,,at a ratio of A and one minus A.
Dialogue: 0,0:50:52.65,0:50:55.12,EN,,0,0,0,,And it will say, oh sure, now I've got two rectangles.
Dialogue: 0,0:51:02.34,0:51:06.54,EN,,0,0,0,,And now it goes off to P1 and says P1, well draw yourself in this rectangle,
Dialogue: 0,0:51:07.36,0:51:11.64,EN,,0,0,0,,and goes off to P2, and says, P2, fine, draw yourself in this rectangle.
Dialogue: 0,0:51:13.28,0:51:16.88,EN,,0,0,0,,The only computation it has to do is figure out what these rectangles are.
Dialogue: 0,0:51:17.36,0:51:23.97,EN,,0,0,0,,Remember a rectangle is specified by an origin and a horizontal vector and a vertical vector.
Dialogue: 0,0:51:23.98,0:51:25.94,EN,,0,0,0,,so it's got to figure out what these things are.
Dialogue: 0,0:51:27.37,0:51:32.29,EN,,0,0,0,,So for this first rectangle, the origin turns out to be the origin of the original rectangle,
Dialogue: 0,0:51:33.64,0:51:37.80,EN,,0,0,0,,and the vertical vector is the same as the vertical vector of the original rectangle.
Dialogue: 0,0:51:38.89,0:51:46.60,EN,,0,0,0,,The horizontal vector is the horizontal vector of the original rectangle scaled by A.
Dialogue: 0,0:51:47.49,0:51:48.90,EN,,0,0,0,,And that's the first rectangle.
Dialogue: 0,0:51:49.46,0:51:52.69,EN,,0,0,0,,The second rectangle, the origin
Dialogue: 0,0:51:54.06,0:51:59.65,EN,,0,0,0,,The second rectangle, the origin is the original origin plus that horizontal vector scaled by A.
Dialogue: 0,0:52:01.20,0:52:03.40,EN,,0,0,0,,The horizontal vector of the second rectangle is
Dialogue: 0,0:52:03.77,0:52:06.04,EN,,0,0,0,,the rest of the horizontal vector of the first one,
Dialogue: 0,0:52:06.34,0:52:11.66,EN,,0,0,0,,which is 1 minus A times the original H,
Dialogue: 0,0:52:12.05,0:52:13.77,EN,,0,0,0,,and the vertical vector is still v.
Dialogue: 0,0:52:15.48,0:52:17.98,EN,,0,0,0,,But basically it goes and constructs these two rectangles,
Dialogue: 0,0:52:18.00,0:52:20.57,EN,,0,0,0,,and the important point is having constructed the rectangles,
Dialogue: 0,0:52:20.93,0:52:24.58,EN,,0,0,0,,it says OK, p1, you draw yourself in there, and p2, you draw yourself in there,
Dialogue: 0,0:52:24.62,0:52:26.18,EN,,0,0,0,,and that's all Beside has to do.
Dialogue: 0,0:52:27.80,0:52:29.30,EN,,0,0,0,,All right, let's look at that piece of code.
Dialogue: 0,0:52:34.33,0:52:35.13,EN,,0,0,0,,Beside
Dialogue: 0,0:52:39.64,0:52:46.44,EN,,0,0,0,,Beside of a picture and another picture with some scaling ratio
Dialogue: 0,0:52:47.84,0:52:53.64,EN,,0,0,0,,is first of all, since it's a picture, a procedure that's going to take a rectangle as argument.
Dialogue: 0,0:52:55.49,0:52:56.56,EN,,0,0,0,,What's it going to do?
Dialogue: 0,0:52:56.76,0:53:02.32,EN,,0,0,0,,It says, p1 draw yourself in some rectangle and p2 draw yourself in some other rectangle.
Dialogue: 0,0:53:03.21,0:53:04.46,EN,,0,0,0,,And now what are those rectangles?
Dialogue: 0,0:53:04.46,0:53:05.48,EN,,0,0,0,,Well here's the computation.
Dialogue: 0,0:53:05.48,0:53:06.54,EN,,0,0,0,,It makes a rectangle,
Dialogue: 0,0:53:07.52,0:53:10.40,EN,,0,0,0,,and this is the algebra I just did on the board: the origin, something;
Dialogue: 0,0:53:10.40,0:53:11.84,EN,,0,0,0,,the horizontal vector, something;
Dialogue: 0,0:53:11.84,0:53:13.44,EN,,0,0,0,,and the vertical vector, something.
Dialogue: 0,0:53:13.97,0:53:14.81,EN,,0,0,0,,For p2
Dialogue: 0,0:53:15.50,0:53:19.78,EN,,0,0,0,,And for p2, the rectangle it wants has some other origin and horizontal vector and vertical vector.
Dialogue: 0,0:53:19.78,0:53:20.70,EN,,0,0,0,,But the important point
Dialogue: 0,0:53:21.21,0:53:27.18,EN,,0,0,0,,is that all it's saying is, p1, go do your thing in one rectangle, and p2, go do your thing in another rectangle.
Dialogue: 0,0:53:27.74,0:53:29.42,EN,,0,0,0,,That's all the Beside has to do.
Dialogue: 0,0:53:30.84,0:53:35.62,EN,,0,0,0,,OK, similarly Rotate--
Dialogue: 0,0:53:36.96,0:53:42.00,EN,,0,0,0,,see if I have this picture A,
Dialogue: 0,0:53:42.97,0:53:46.12,EN,,0,0,0,,and I want to look at say rotating A by 90 degrees,
Dialogue: 0,0:53:46.37,0:53:51.92,EN,,0,0,0,,what that should mean is, well take this rectangle,
Dialogue: 0,0:53:53.94,0:53:58.44,EN,,0,0,0,,which is origin and horizontal vector and vertical vector,
Dialogue: 0,0:53:58.78,0:54:03.18,EN,,0,0,0,,and now pretend that it's really the rectangle that looks like this,
Dialogue: 0,0:54:03.74,0:54:09.12,EN,,0,0,0,,which has an origin and a horizontal vector up here, and a vertical vector there,
Dialogue: 0,0:54:09.60,0:54:12.46,EN,,0,0,0,,and now draw yourself with respect to that rectangle.
Dialogue: 0,0:54:13.26,0:54:15.04,EN,,0,0,0,,Let me show you that as a procedure.
Dialogue: 0,0:54:17.02,0:54:19.85,EN,,0,0,0,,All right, so we'll Rotate 90 of the picture,
Dialogue: 0,0:54:20.61,0:54:22.96,EN,,0,0,0,,because again, a procedure for rectangle,
Dialogue: 0,0:54:23.25,0:54:26.12,EN,,0,0,0,,which says, OK picture, draw yourself in some rectangle;
Dialogue: 0,0:54:27.21,0:54:30.66,EN,,0,0,0,,and then this algebra is the transformation on the rectangle.
Dialogue: 0,0:54:30.66,0:54:33.84,EN,,0,0,0,,It's the one which makes it look like the rectangle is sideways,
Dialogue: 0,0:54:33.86,0:54:36.52,EN,,0,0,0,,the origin is someplace else and the vertical vector is someplace else,
Dialogue: 0,0:54:37.13,0:54:39.74,EN,,0,0,0,,and the horizontal vector is someplace else, and vertical vector is someplace else.
Dialogue: 0,0:54:46.76,0:54:49.90,EN,,0,0,0,,OK, again notice, the crucial thing that's going on here
Dialogue: 0,0:54:50.53,0:55:00.97,EN,,0,0,0,,is you're using the representation of pictures as procedures to automatically get the closure property,
Dialogue: 0,0:55:01.74,0:55:05.22,EN,,0,0,0,,because what happens is, Beside just has this thing p1.
Dialogue: 0,0:55:05.22,0:55:09.40,EN,,0,0,0,,Beside doesn't care if that's a primitive picture or it's line segments
Dialogue: 0,0:55:09.61,0:55:12.69,EN,,0,0,0,,if p1 is, itself, the result of doing Aboves or Besides or Rotates.
Dialogue: 0,0:55:12.72,0:55:16.08,EN,,0,0,0,,All Beside has to know about, say, p1
Dialogue: 0,0:55:16.29,0:55:19.73,EN,,0,0,0,,p1 is that if you hand p1 a rectangle, it will cause something to be drawn.
Dialogue: 0,0:55:21.04,0:55:25.98,EN,,0,0,0,,And above that level, Beside just doesn't-- it's none of its business how p1 accomplishes that drawing.
Dialogue: 0,0:55:27.73,0:55:32.25,EN,,0,0,0,,All right, so you're using the procedural representation to ensure this closure.
Dialogue: 0,0:55:35.64,0:55:40.81,EN,,0,0,0,,So implementing pictures as procedures makes these means of combination,
Dialogue: 0,0:55:41.18,0:55:43.93,EN,,0,0,0,,both pretty simple and also, I think, elegant.
Dialogue: 0,0:55:45.92,0:55:48.22,EN,,0,0,0,,But that's not the real punchline.
Dialogue: 0,0:55:49.28,0:55:53.52,EN,,0,0,0,,The real punchline comes when you look at the means of abstraction in this language.
Dialogue: 0,0:55:54.70,0:55:56.24,EN,,0,0,0,,Because what have we done?
Dialogue: 0,0:55:56.24,0:56:03.72,EN,,0,0,0,,We've implemented the means of combination themselves as procedures.
Dialogue: 0,0:56:05.85,0:56:09.38,EN,,0,0,0,,And what that means is that when we go to abstract in this language,
Dialogue: 0,0:56:10.17,0:56:15.69,EN,,0,0,0,,everything that Lisp supplies us for manipulating procedures
Dialogue: 0,0:56:16.33,0:56:21.45,EN,,0,0,0,,automatically available to do things in this picture language.
Dialogue: 0,0:56:21.92,0:56:29.74,EN,,0,0,0,,The technical term I want to say is not only is this language implemented in Lisp, obviously it is,
Dialogue: 0,0:56:29.76,0:56:32.58,EN,,0,0,0,,but the language is nicely embedded in Lisp.
Dialogue: 0,0:56:37.64,0:56:42.08,EN,,0,0,0,,What I mean is by embedding the language in this way,
Dialogue: 0,0:56:42.90,0:56:48.86,EN,,0,0,0,,all the power of Lisp is automatically available as an extension to whatever you want to do.
Dialogue: 0,0:56:50.06,0:56:51.68,EN,,0,0,0,,And what do I mean by that?
Dialogue: 0,0:56:51.97,0:57:02.94,EN,,0,0,0,,Example: say, suppose I want to make a thing that takes four pictures A, B, C and D,
Dialogue: 0,0:57:03.76,0:57:07.06,EN,,0,0,0,,and makes a configuration that looks like this.
Dialogue: 0,0:57:12.50,0:57:16.96,EN,,0,0,0,,Well you might call that, you know, four pictures or something, four-pict configuration.
Dialogue: 0,0:57:16.96,0:57:17.70,EN,,0,0,0,,How do I do that?
Dialogue: 0,0:57:17.70,0:57:18.68,EN,,0,0,0,,Well I can obviously do that.
Dialogue: 0,0:57:18.68,0:57:23.33,EN,,0,0,0,,I just write a procedure that takes B above D
Dialogue: 0,0:57:24.13,0:57:25.85,EN,,0,0,0,,and A above C
Dialogue: 0,0:57:26.09,0:57:27.70,EN,,0,0,0,,and puts those things beside each other.
Dialogue: 0,0:57:28.24,0:57:31.82,EN,,0,0,0,,So I automatically have Lisp's ability to do procedure composition.
Dialogue: 0,0:57:32.92,0:57:35.82,EN,,0,0,0,,And I didn't have to make that specifically in the picture language.
Dialogue: 0,0:57:35.82,0:57:39.92,EN,,0,0,0,,It's automatic from the fact that the means of combination are themselves procedures.
Dialogue: 0,0:57:40.96,0:57:44.18,EN,,0,0,0,,Or suppose I wanted to do something a little bit more complicated.
Dialogue: 0,0:57:44.18,0:57:46.50,EN,,0,0,0,,I wanted to put in a parameter so that for each of these,
Dialogue: 0,0:57:46.52,0:57:50.08,EN,,0,0,0,,I could independently specify a rotation by 90 degrees.
Dialogue: 0,0:57:50.41,0:57:52.64,EN,,0,0,0,,That's just putting a parameter in the procedure.
Dialogue: 0,0:57:53.17,0:57:54.56,EN,,0,0,0,,It's automatically there.
Dialogue: 0,0:57:54.80,0:57:57.84,EN,,0,0,0,,Right, it automatically comes from the embedding.
Dialogue: 0,0:57:58.16,0:58:05.36,EN,,0,0,0,,Or even more, suppose I wanted to, you know, use recursion.
Dialogue: 0,0:58:06.16,0:58:10.78,EN,,0,0,0,,Let's look at a recursive means of combination on pictures.
Dialogue: 0,0:58:10.78,0:58:14.64,EN,,0,0,0,,I could say define-- let's see if you can figure out what this one is--
Dialogue: 0,0:58:14.69,0:58:18.97,EN,,0,0,0,,suppose I say define what it means to right-push a picture,
Dialogue: 0,0:58:22.84,0:58:29.80,EN,,0,0,0,,right-push a picture and some integer N and some scale factor A.
Dialogue: 0,0:58:31.46,0:58:41.22,EN,,0,0,0,,I'll define this to say if N equals 0, then the answer is the picture.
Dialogue: 0,0:58:42.20,0:58:54.02,EN,,0,0,0,,Otherwise I'm going to put-- oops, name change: P.
Dialogue: 0,0:58:55.88,0:59:00.21,EN,,0,0,0,,Otherwise, I'm going to take P and put it beside
Dialogue: 0,0:59:00.92,0:59:18.30,EN,,0,0,0,,the results of recursively right-pushing P with N minus 1 and A and use a scale factor of A. OK,
Dialogue: 0,0:59:24.72,0:59:31.12,EN,,0,0,0,,so if N 0 , it's P. Otherwise I put P with a scale factor of A--
Dialogue: 0,0:59:31.12,0:59:32.80,EN,,0,0,0,,I'm sorry I didn't align this right--
Dialogue: 0,0:59:33.66,0:59:38.50,EN,,0,0,0,,recursively beside the result of right-pushing P, N minus 1 times with a scale factor of A.
Dialogue: 0,0:59:38.50,0:59:42.00,EN,,0,0,0,,There's a recursive means of combination.
Dialogue: 0,0:59:43.78,0:59:44.76,EN,,0,0,0,,What's that look like?
Dialogue: 0,0:59:44.76,0:59:45.90,EN,,0,0,0,,Well, here's what it looks like.
Dialogue: 0,0:59:46.04,0:59:56.04,EN,,0,0,0,,There's George right-pushed against himself twice with a scale factor of 0.75.
Dialogue: 0,0:59:59.26,1:00:00.72,EN,,0,0,0,,Where'd that come from?
Dialogue: 0,1:00:00.72,1:00:02.34,EN,,0,0,0,,How did I get all this fancy recursion?
Dialogue: 0,1:00:02.34,1:00:05.24,EN,,0,0,0,,And the answer is just automatic, absolutely automatic.
Dialogue: 0,1:00:05.24,1:00:09.80,EN,,0,0,0,,Since these are procedures, the embedding says, well sure, I can define recursive procedures.
Dialogue: 0,1:00:10.36,1:00:11.68,EN,,0,0,0,,I didn't have to arrange that.
Dialogue: 0,1:00:13.56,1:00:16.42,EN,,0,0,0,,And of course, we can do more complicated things of the same sort.
Dialogue: 0,1:00:16.42,1:00:18.21,EN,,0,0,0,,I could make something that does an up-push.
Dialogue: 0,1:00:18.42,1:00:22.60,EN,,0,0,0,,Right, that sort of goes like this, by recursively putting something above.
Dialogue: 0,1:00:22.60,1:00:26.54,EN,,0,0,0,,Or I could make something that, sort of, was this scheme.
Dialogue: 0,1:00:26.56,1:00:28.85,EN,,0,0,0,,I might start out with a picture
Dialogue: 0,1:00:29.78,1:00:37.16,EN,,0,0,0,,and then, sort of, recursively both push it aside and above
Dialogue: 0,1:00:37.57,1:00:38.92,EN,,0,0,0,,and that might put something there.
Dialogue: 0,1:00:39.52,1:00:41.82,EN,,0,0,0,,And then up here I put the same recursive thing,
Dialogue: 0,1:00:42.36,1:00:44.20,EN,,0,0,0,,and I might end up with something like this.
Dialogue: 0,1:00:45.40,1:00:52.50,EN,,0,0,0,,Right, so there's a procedure that's a little bit more complicated than right-push but not much.
Dialogue: 0,1:00:53.64,1:00:58.14,EN,,0,0,0,,I just do an Above and a Beside, rather than just a Beside.
Dialogue: 0,1:01:01.12,1:01:06.78,EN,,0,0,0,,Now if I take that and apply that with the idea of putting four pictures together,
Dialogue: 0,1:01:07.53,1:01:08.65,EN,,0,0,0,,which I can surely do;
Dialogue: 0,1:01:09.01,1:01:14.17,EN,,0,0,0,,and I go and I apply that to Q, which we defined before, right,
Dialogue: 0,1:01:15.97,1:01:18.73,EN,,0,0,0,,what I end up with this is this thing,
Dialogue: 0,1:01:20.14,1:01:25.26,EN,,0,0,0,,which is, sort of, the square limit of Q, done twice.
Dialogue: 0,1:01:28.18,1:01:32.25,EN,,0,0,0,,Right, and then we can compare that with Escher's "Square Limit."
Dialogue: 0,1:01:32.88,1:01:34.53,EN,,0,0,0,,And you see, it's sort of the same idea.
Dialogue: 0,1:01:34.74,1:01:36.94,EN,,0,0,0,,Escher's is, of course, much, much prettier.
Dialogue: 0,1:01:36.94,1:01:44.04,EN,,0,0,0,,If we go back and look at George, right, if we go look at George here--
Dialogue: 0,1:01:44.38,1:01:47.37,EN,,0,0,0,,see, I started with a fairly arbitrary design
Dialogue: 0,1:01:47.42,1:01:49.26,EN,,0,0,0,,this picture of George and did things with it.
Dialogue: 0,1:01:51.22,1:01:53.14,EN,,0,0,0,,Right, whereas if we go look at the Escher picture, right,
Dialogue: 0,1:01:54.08,1:01:56.14,EN,,0,0,0,,the Escher picture is not an arbitrary design.
Dialogue: 0,1:01:56.14,1:01:57.66,EN,,0,0,0,,It's this very, very clever thing,
Dialogue: 0,1:01:57.89,1:02:00.20,EN,,0,0,0,,so that when you take this fish body
Dialogue: 0,1:02:01.82,1:02:04.97,EN,,0,0,0,,and Rotate it and shrink it down, it bleeds into the next one really nicely.
Dialogue: 0,1:02:07.40,1:02:11.48,EN,,0,0,0,,And of course with George, I didn't really do anything like that.
Dialogue: 0,1:02:12.12,1:02:13.90,EN,,0,0,0,,So if we look at George,
Dialogue: 0,1:02:15.41,1:02:18.64,EN,,0,0,0,,right, there's a little bit of match up, but not very nice, and it's pretty arbitrary.
Dialogue: 0,1:02:18.64,1:02:21.53,EN,,0,0,0,,One very nice project, by the way,
Dialogue: 0,1:02:22.30,1:02:27.54,EN,,0,0,0,,would be to write a procedure that could take some basic figure like this George thing
Dialogue: 0,1:02:27.86,1:02:29.62,EN,,0,0,0,,and start moving the ends of the lines around,
Dialogue: 0,1:02:29.86,1:02:31.20,EN,,0,0,0,,so you got a really nice one
Dialogue: 0,1:02:32.13,1:02:34.06,EN,,0,0,0,,when you went and did that "Square Limit" process.
Dialogue: 0,1:02:34.68,1:02:36.30,EN,,0,0,0,,That'd be a really nice thing to think about.
Dialogue: 0,1:02:38.08,1:02:39.72,EN,,0,0,0,,Well so, we can combine things.
Dialogue: 0,1:02:39.72,1:02:41.04,EN,,0,0,0,,We can recursive procedures.
Dialogue: 0,1:02:41.04,1:02:43.48,EN,,0,0,0,,We can do all kinds of things, and that's all automatic.
Dialogue: 0,1:02:44.60,1:02:48.52,EN,,0,0,0,,Right, the important point, the difference between merely implementing something in a language
Dialogue: 0,1:02:48.69,1:02:50.44,EN,,0,0,0,,and embedding something in the language,
Dialogue: 0,1:02:50.44,1:02:53.72,EN,,0,0,0,,so that you don't lose the original power of the language, and what Lisp is great at,
Dialogue: 0,1:02:54.76,1:02:57.62,EN,,0,0,0,,see Lisp is a lousy language for doing any particular problem.
Dialogue: 0,1:02:57.62,1:03:02.10,EN,,0,0,0,,What it's good for is figuring out the right language that you want and embedding that in Lisp.
Dialogue: 0,1:03:02.10,1:03:05.44,EN,,0,0,0,,That's the real power of this approach to design.
Dialogue: 0,1:03:05.69,1:03:06.82,EN,,0,0,0,,Of course, we can go further.
Dialogue: 0,1:03:06.82,1:03:08.81,EN,,0,0,0,,See, you saw the other thing that we can do in Lisp
Dialogue: 0,1:03:09.21,1:03:17.52,EN,,0,0,0,,is capture general methods of doing things as higher order procedures.
Dialogue: 0,1:03:19.09,1:03:22.57,EN,,0,0,0,,And you probably just from me drawing it got the idea that right-push
Dialogue: 0,1:03:23.78,1:03:26.61,EN,,0,0,0,,and the analogous thing where you push something up and up and up and up
Dialogue: 0,1:03:26.93,1:03:33.82,EN,,0,0,0,,and this corner push thing are all generalizations of a common kind of idea.
Dialogue: 0,1:03:34.72,1:03:37.20,EN,,0,0,0,,So just to illustrate and give you practice in looking at a
Dialogue: 0,1:03:37.98,1:03:40.65,EN,,0,0,0,,at a fairly convoluted use of higher order procedures,
Dialogue: 0,1:03:41.12,1:03:47.24,EN,,0,0,0,,let me show you the general idea of pushing some means of combination to recursively repeat it.
Dialogue: 0,1:03:48.30,1:03:50.70,EN,,0,0,0,,So here's a good one to puzzle out.
Dialogue: 0,1:03:51.22,1:04:00.70,EN,,0,0,0,,We'll define it what it means to push using a means of combination.
Dialogue: 0,1:04:01.49,1:04:04.88,EN,,0,0,0,,Comb is going to be something like the Beside or Above.
Dialogue: 0,1:04:06.18,1:04:07.06,EN,,0,0,0,,Well what's that going to be.
Dialogue: 0,1:04:07.06,1:04:12.06,EN,,0,0,0,,That's going to be a procedure, remember what Beside actually was, right.
Dialogue: 0,1:04:13.22,1:04:15.18,EN,,0,0,0,,It took a picture,
Dialogue: 0,1:04:15.96,1:04:18.08,EN,,0,0,0,,took two pictures and a scale factor.
Dialogue: 0,1:04:18.62,1:04:24.28,EN,,0,0,0,,Using that I produced something that took a level number and a picture and a scale factor,
Dialogue: 0,1:04:24.28,1:04:25.45,EN,,0,0,0,,that I called right-push.
Dialogue: 0,1:04:26.16,1:04:33.66,EN,,0,0,0,,So this is going to be something that takes a picture, a level number and a scale factor, and it's going to say--
Dialogue: 0,1:04:36.16,1:04:39.12,EN,,0,0,0,,I'm going to do some repeated operation.
Dialogue: 0,1:04:39.45,1:04:46.62,EN,,0,0,0,,I'm going to repeatedly apply the procedure which takes a picture
Dialogue: 0,1:04:48.40,1:04:50.69,EN,,0,0,0,,and applies the means of combination
Dialogue: 0,1:04:51.20,1:04:59.08,EN,,0,0,0,,to the picture and the original picture and the one I took in here and the scale factor,
Dialogue: 0,1:05:02.26,1:05:07.28,EN,,0,0,0,,and I do the thing which repeats this procedure N times,
Dialogue: 0,1:05:12.04,1:05:16.20,EN,,0,0,0,,and I apply that whole thing to my original picture.
Dialogue: 0,1:05:19.56,1:05:24.48,EN,,0,0,0,,Repeated here, in case you haven't seen it, is another higher order procedure
Dialogue: 0,1:05:24.53,1:05:28.34,EN,,0,0,0,,that takes a procedure and a number
Dialogue: 0,1:05:29.54,1:05:34.29,EN,,0,0,0,,and returns for you another procedure that applies this procedure N times.
Dialogue: 0,1:05:36.04,1:05:39.30,EN,,0,0,0,,And I think some of you have already written repeated as an exercise,
Dialogue: 0,1:05:39.70,1:05:43.01,EN,,0,0,0,,but if you haven't, it's a very good exercise in thinking about higher order procedures.
Dialogue: 0,1:05:43.84,1:05:46.90,EN,,0,0,0,,But in any case, the result of this repeated is what I apply to picture.
Dialogue: 0,1:05:49.46,1:05:52.38,EN,,0,0,0,,And having done that, that's going to capture the --
Dialogue: 0,1:05:53.12,1:05:57.73,EN,,0,0,0,,that is the thing, the way I got from the idea of Beside to the idea of right-push
Dialogue: 0,1:05:59.01,1:06:13.17,EN,,0,0,0,,So having done that, I could say define right-push to be push of Beside.
Dialogue: 0,1:06:17.65,1:06:20.32,EN,,0,0,0,,Or if I say, define up-push to be push of Above
Dialogue: 0,1:06:20.34,1:06:25.48,EN,,0,0,0,,I'd get the analogous thing or define corner-push to be push of some appropriate thing that did both the Beside and Above,
Dialogue: 0,1:06:25.49,1:06:26.70,EN,,0,0,0,,or I could push anything.
Dialogue: 0,1:06:28.26,1:06:34.76,EN,,0,0,0,,Anyway this is, if you're having trouble with lambdas, this is an excellent exercise in figuring out what this means.
Dialogue: 0,1:06:38.98,1:06:41.00,EN,,0,0,0,,OK, well there's a lot to learn from this example.
Dialogue: 0,1:06:42.18,1:06:49.80,EN,,0,0,0,,The main point I've been welling on is the notion of nicely embedding a language inside another language.
Dialogue: 0,1:06:50.66,1:06:55.62,EN,,0,0,0,,Right, so that all the power of this language like Lisp of the surrounding language
Dialogue: 0,1:06:55.92,1:07:00.28,EN,,0,0,0,,is still accessible to you and appears as a natural extension of the language that you built.
Dialogue: 0,1:07:00.98,1:07:04.00,EN,,0,0,0,,That's one thing that this example shows very well.
Dialogue: 0,1:07:08.14,1:07:10.94,EN,,0,0,0,,Another thing is, if you go back and think about that,
Dialogue: 0,1:07:10.94,1:07:12.28,EN,,0,0,0,,what's procedures and what's data.
Dialogue: 0,1:07:12.28,1:07:16.20,EN,,0,0,0,,You know, by the time we get up to here, my God, what's going on.
Dialogue: 0,1:07:16.20,1:07:19.66,EN,,0,0,0,,I mean, this is some procedure, and it takes a picture and an argument,
Dialogue: 0,1:07:19.66,1:07:20.36,EN,,0,0,0,,and what's a picture.
Dialogue: 0,1:07:20.36,1:07:23.82,EN,,0,0,0,,Well, a picture itself, as you remember, was a procedure, and that took a rectangle.
Dialogue: 0,1:07:23.82,1:07:25.82,EN,,0,0,0,,And a rectangle is some abstraction.
Dialogue: 0,1:07:26.09,1:07:28.13,EN,,0,0,0,,And I hope now that by now you're completely lost
Dialogue: 0,1:07:29.14,1:07:33.74,EN,,0,0,0,,as to the question of what in the system is procedure and what's data.
Dialogue: 0,1:07:33.74,1:07:34.78,EN,,0,0,0,,You see, there isn't any difference.
Dialogue: 0,1:07:35.49,1:07:36.44,EN,,0,0,0,,There really isn't.
Dialogue: 0,1:07:37.93,1:07:41.42,EN,,0,0,0,,And you might think of a picture sometimes as a procedure and sometimes as data,
Dialogue: 0,1:07:41.84,1:07:44.90,EN,,0,0,0,,but that's just, sort of, you know, making you feel comfortable.
Dialogue: 0,1:07:44.90,1:07:47.30,EN,,0,0,0,,It's really both in some sense or neither in some sense.
Dialogue: 0,1:07:49.92,1:08:02.20,EN,,0,0,0,,OK, there's a more general point about the structure of the system as creating a language,
Dialogue: 0,1:08:02.52,1:08:06.74,EN,,0,0,0,,viewing the engineering design process as one of creating language or
Dialogue: 0,1:08:07.84,1:08:13.97,EN,,0,0,0,,or rather one of creating a sort of sequence of layers of language.
Dialogue: 0,1:08:14.77,1:08:20.01,EN,,0,0,0,,You see, there's this methodology, or maybe I should say mythology,
Dialogue: 0,1:08:20.74,1:08:24.90,EN,,0,0,0,,that's, sort of, charitably called software, quote, engineering.
Dialogue: 0,1:08:25.21,1:08:28.04,EN,,0,0,0,,All right, and what does it say, it's says well, you go and you figure out your task,
Dialogue: 0,1:08:28.04,1:08:30.04,EN,,0,0,0,,and you figure out exactly what you want to do.
Dialogue: 0,1:08:30.40,1:08:32.20,EN,,0,0,0,,And once you figure out exactly what you want to do,
Dialogue: 0,1:08:32.22,1:08:34.54,EN,,0,0,0,,you find out that it breaks out into three sub-tasks,
Dialogue: 0,1:08:34.54,1:08:35.76,EN,,0,0,0,,and you go and you start working on--
Dialogue: 0,1:08:35.97,1:08:38.94,EN,,0,0,0,,and you work on this sub-task, and you figure out exactly what that is.
Dialogue: 0,1:08:38.94,1:08:43.04,EN,,0,0,0,,And you find out that that breaks down into three sub-tasks, and you specify them completely,
Dialogue: 0,1:08:43.04,1:08:47.32,EN,,0,0,0,,and you go and you work on those two, and you work on this sub-one, and you specify that exactly.
Dialogue: 0,1:08:47.32,1:08:51.10,EN,,0,0,0,,And then finally when you're done, you come back way up here, and you work on your second sub-task,
Dialogue: 0,1:08:51.10,1:08:53.40,EN,,0,0,0,,and specify that out and work it out.
Dialogue: 0,1:08:53.40,1:08:57.64,EN,,0,0,0,,And then you end up with-- you end up at the end with this beautiful edifice.
Dialogue: 0,1:08:57.64,1:09:00.25,EN,,0,0,0,,Right, you end up with a marvelous tree,
Dialogue: 0,1:09:00.89,1:09:08.24,EN,,0,0,0,,that where you've broken your task into sub-tasks and broken each of these into sub-tasks and broken those into sub-tasks, right.
Dialogue: 0,1:09:09.88,1:09:15.02,EN,,0,0,0,,And each of these nodes is exactly and precisely defined
Dialogue: 0,1:09:15.26,1:09:18.66,EN,,0,0,0,,to do the wonderful, beautiful task to make it fit into the whole edifice
Dialogue: 0,1:09:18.96,1:09:21.14,EN,,0,0,0,,Right, that's this mythology.
Dialogue: 0,1:09:21.14,1:09:25.92,EN,,0,0,0,,See only a computer scientist could possibly believe that you build a complex system like that
Dialogue: 0,1:09:27.48,1:09:32.80,EN,,0,0,0,,Right. Contrast that with this Henderson example.
Dialogue: 0,1:09:32.80,1:09:34.30,EN,,0,0,0,,It didn't work like that.
Dialogue: 0,1:09:35.26,1:09:39.33,EN,,0,0,0,,What happened was that there was a sequence of layers of language.
Dialogue: 0,1:09:41.06,1:09:42.05,EN,,0,0,0,,What happened?
Dialogue: 0,1:09:42.18,1:09:48.76,EN,,0,0,0,,There was a layer of a thing that allowed us to build primitive pictures.
Dialogue: 0,1:09:51.69,1:09:56.24,EN,,0,0,0,,There's primitive pictures and that was a language.
Dialogue: 0,1:09:56.32,1:09:57.84,EN,,0,0,0,,I didn't say much about it.
Dialogue: 0,1:09:58.22,1:09:59.58,EN,,0,0,0,,We talked about how to construct George,
Dialogue: 0,1:09:59.61,1:10:04.88,EN,,0,0,0,,but that was a language where you talked about vectors and line segments and points and where they sat in the unit square.
Dialogue: 0,1:10:06.42,1:10:11.29,EN,,0,0,0,,And then on top of that, right, on top of that--
Dialogue: 0,1:10:11.97,1:10:14.10,EN,,0,0,0,,so this is the language of primitive pictures.
Dialogue: 0,1:10:17.08,1:10:20.36,EN,,0,0,0,,Right, talking about line segments in particular pictures in the unit square.
Dialogue: 0,1:10:21.40,1:10:23.80,EN,,0,0,0,,On top of that was a whole language.
Dialogue: 0,1:10:24.05,1:10:30.86,EN,,0,0,0,,There was a language of geometric combinators,
Dialogue: 0,1:10:32.66,1:10:36.62,EN,,0,0,0,,a language of geometric positions,
Dialogue: 0,1:10:38.77,1:10:46.50,EN,,0,0,0,,which talks about things like Above and Beside and right-push and Rotate.
Dialogue: 0,1:10:48.04,1:10:55.70,EN,,0,0,0,,And those things, sort of, happened with reference to the things that are talked about in this language.
Dialogue: 0,1:10:58.57,1:11:00.93,EN,,0,0,0,,And then if we like, we saw that above that
Dialogue: 0,1:11:02.61,1:11:15.10,EN,,0,0,0,,there was sort of a language of schemes of combination.
Dialogue: 0,1:11:21.25,1:11:22.44,EN,,0,0,0,,For example, push,
Dialogue: 0,1:11:24.45,1:11:27.88,EN,,0,0,0,,which talked about repeatedly doing something over with a scale factor.
Dialogue: 0,1:11:28.38,1:11:31.28,EN,,0,0,0,,And the things that were being discussed in that language
Dialogue: 0,1:11:31.50,1:11:34.34,EN,,0,0,0,,were, sort of, the things that happened down here.
Dialogue: 0,1:11:36.30,1:11:42.76,EN,,0,0,0,,So what you have is, at each level, the objects that are being talked about
Dialogue: 0,1:11:44.68,1:11:47.00,EN,,0,0,0,,are the things that were erected the previous level.
Dialogue: 0,1:11:48.08,1:11:52.06,EN,,0,0,0,,What's the difference between this thing and this thing?
Dialogue: 0,1:11:53.34,1:11:54.18,EN,,0,0,0,,The answer is
Dialogue: 0,1:11:56.14,1:12:01.73,EN,,0,0,0,,that over here in the tree, each node, and in fact, each decomposition down here,
Dialogue: 0,1:12:02.14,1:12:05.25,EN,,0,0,0,,is being designed to do a specific task,
Dialogue: 0,1:12:07.50,1:12:08.88,EN,,0,0,0,,whereas in the other scheme,
Dialogue: 0,1:12:09.21,1:12:14.80,EN,,0,0,0,,what you have is a full range of linguistic power at each level.
Dialogue: 0,1:12:16.00,1:12:18.08,EN,,0,0,0,,See what's happening there, at any level,
Dialogue: 0,1:12:20.24,1:12:22.72,EN,,0,0,0,,it's not being set up to do a particular task.
Dialogue: 0,1:12:23.14,1:12:26.17,EN,,0,0,0,,It's being set up to talk about a whole range of things.
Dialogue: 0,1:12:27.62,1:12:30.78,EN,,0,0,0,,The consequence of that for design
Dialogue: 0,1:12:31.14,1:12:35.58,EN,,0,0,0,,is that something that's designed in that method is likely to be more robust,
Dialogue: 0,1:12:36.61,1:12:38.20,EN,,0,0,0,,where by robust, I mean
Dialogue: 0,1:12:38.44,1:12:41.24,EN,,0,0,0,,that if you go and make some change in your description,
Dialogue: 0,1:12:42.70,1:12:48.04,EN,,0,0,0,,it's more likely to be captured by a corresponding change,
Dialogue: 0,1:12:49.22,1:12:52.60,EN,,0,0,0,,in the way that the language is implemented at the next level up,
Dialogue: 0,1:12:54.29,1:12:56.58,EN,,0,0,0,,right, because you've made these levels full.
Dialogue: 0,1:12:56.62,1:12:59.66,EN,,0,0,0,,So you're not talking about a particular thing like Beside.
Dialogue: 0,1:12:59.94,1:13:03.78,EN,,0,0,0,,You've given yourself a whole vocabulary to express things of that sort,
Dialogue: 0,1:13:04.77,1:13:07.02,EN,,0,0,0,,so if you go and change your specifications a little bit,
Dialogue: 0,1:13:07.02,1:13:11.38,EN,,0,0,0,,it's more likely that your methodology will able to adapt to capture that change,
Dialogue: 0,1:13:12.69,1:13:15.02,EN,,0,0,0,,whereas a design like this is not going to be robust,
Dialogue: 0,1:13:15.02,1:13:17.08,EN,,0,0,0,,because if I go and change something that's in here,
Dialogue: 0,1:13:17.53,1:13:21.69,EN,,0,0,0,,that might affect the entire way that I decomposed everything down, further down the tree.
Dialogue: 0,1:13:23.20,1:13:29.74,EN,,0,0,0,,Right, so very big difference in outlook in decomposition, levels of language rather than, sort of, a strict hierarchy.
Dialogue: 0,1:13:30.52,1:13:33.02,EN,,0,0,0,,Not only that, but when you have levels of language
Dialogue: 0,1:13:33.50,1:13:35.92,EN,,0,0,0,,you've given yourself a different vocabularies
Dialogue: 0,1:13:36.45,1:13:38.74,EN,,0,0,0,,for talking about the design at different levels.
Dialogue: 0,1:13:38.74,1:13:40.92,EN,,0,0,0,,So if we go back and look at George one last time,
Dialogue: 0,1:13:41.90,1:13:44.08,EN,,0,0,0,,if I wanted to change this picture George,
Dialogue: 0,1:13:45.85,1:13:48.68,EN,,0,0,0,,see suddenly I have a whole different ways of describing the change.
Dialogue: 0,1:13:48.68,1:13:56.08,EN,,0,0,0,,Like for example, I may want to go to the basic primitive design and move the endpoint of some vector.
Dialogue: 0,1:13:57.76,1:14:00.76,EN,,0,0,0,,That's a change that I would discuss at the lowest level.
Dialogue: 0,1:14:01.00,1:14:02.50,EN,,0,0,0,,I would say the endpoint is somewhere else.
Dialogue: 0,1:14:03.34,1:14:07.98,EN,,0,0,0,,Or I might come up and say, well the next thing I wanted to do, this little replicated element,
Dialogue: 0,1:14:09.10,1:14:10.94,EN,,0,0,0,,I might want to do by something else.
Dialogue: 0,1:14:10.94,1:14:13.84,EN,,0,0,0,,I might want to put a scale factor in that Beside.
Dialogue: 0,1:14:13.84,1:14:19.34,EN,,0,0,0,,That's a change that I would discuss at the next level of design, the level of combinators.
Dialogue: 0,1:14:19.34,1:14:25.05,EN,,0,0,0,,Or I might want to say, I might want to change the basic way that I took this pattern
Dialogue: 0,1:14:26.49,1:14:30.48,EN,,0,0,0,,and made some recursive decomposition, maybe not bleeding out toward the corners or something else.
Dialogue: 0,1:14:31.16,1:14:34.18,EN,,0,0,0,,That would be a change that I would discuss at the highest level.
Dialogue: 0,1:14:34.18,1:14:36.37,EN,,0,0,0,,And because I've structured the system to be this way,
Dialogue: 0,1:14:36.52,1:14:39.62,EN,,0,0,0,,I have all these vocabularies for talking about change in different ways
Dialogue: 0,1:14:39.65,1:14:42.48,EN,,0,0,0,,and a lot of flexibility to decide which one's appropriate.
Dialogue: 0,1:14:44.74,1:14:51.05,EN,,0,0,0,,OK, well that's sort of a big point about the difference in software methodology that comes out from Lisp,
Dialogue: 0,1:14:51.25,1:14:55.45,EN,,0,0,0,,and it all comes again, out of the notion that really, the design process
Dialogue: 0,1:14:56.12,1:14:59.62,EN,,0,0,0,,is not so much implementing programs as implementing languages.
Dialogue: 0,1:14:59.62,1:15:01.09,EN,,0,0,0,,And that's really the power of Lisp.
Dialogue: 0,1:15:02.21,1:15:03.61,EN,,0,0,0,,OK, thank you. Let's take a break.
Dialogue: 0,1:15:05.69,1:15:23.37,Declare,,0,0,0,,{\fad(500,500)}MIT OpenCourseWare\Nhttp://ocw.mit.edu
Dialogue: 0,1:15:05.69,1:15:23.37,Declare,,0,0,0,,{\an2\fad(500,500)}Project Repo\Nhttps://github.com/DeathKing/Learning-SICP
Dialogue: 0,1:15:23.37,1:15:25.37,Default,,0,0,0,,
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Ruby
1
https://gitee.com/jacklisp/Learning-SICP.git
git@gitee.com:jacklisp/Learning-SICP.git
jacklisp
Learning-SICP
Learning-SICP
master

搜索帮助