> <\body> <\hide-preamble> >>> <\slideshow> <\slide> \; \; \; \; \<#57FA\>\<#7840\>SICP 08>|>>|\<#6D6A\>\<#718A\>\<#732B\>\<#513F\>>>>|>>|\<#7406\>\<#6570\>\<#7684\>\<#6570\>\<#636E\>\<#62BD\>\<#8C61\>>> <\slide> \<#57FA\>\<#7840\>SICP\<#FF1A\>\<#7B2C\>8\<#8BFE\>> <\wide-tabular> || \<#6570\>\<#636E\>\<#62BD\>\<#8C61\>\<#5BFC\>\<#5F15\> > |<\cell> <\very-large> >| \<#5B9E\>\<#4F8B\>\<#FF1A\>\<#6709\>\<#7406\>\<#6570\>\<#7684\>\<#7B97\>\<#672F\>\<#8FD0\>\<#7B97\> |<\cell> Example: Arithmetic Operations for Rational Numbers >| \<#62BD\>\<#8C61\>\<#5C42\>\<#7EA7\> |<\cell> Abstraction Barriers >| \<#6570\>\<#636E\>\<#610F\>\<#5473\>\<#7740\>\<#4EC0\>\<#4E48\> |<\cell> What Is Meant by Data? >>> \; \<#7A0B\>\<#7684\>\<#57FA\>\<#672C\>\<#539F\>\<#7406\>\<#662F\>\<#5BF9\>\<#6570\>\<#636E\>\<#548C\>\<#8BA1\>\<#7B97\>\<#7684\>\<#7EC4\>\<#5408\>\<#548C\>\<#62BD\>\<#8C61\>> \; \; \; <\slide> \<#7406\>\<#6570\>\<#4E0E\>\<#5206\>\<#5F0F\>> \<#9884\>\<#5B9A\>\<#4E49\>\<#51FD\>\<#6570\>\<#FF1A\>\<#5206\>\<#5F0F\>\<#3001\>\<#5206\>\<#5F0F\>\<#663E\>\<#3001\>\<#5206\>\<#5B50\>\<#3001\>\<#5206\>\<#6BCD\> <\with|par-columns|2> <\session|scheme|default> <\folded-io|Scheme] > (define \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\> (\<#5206\>\<#5F0F\> 1 2)) <|folded-io> (1 . 2) <\folded-io|Scheme] > (define \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\> (\<#5206\>\<#5F0F\> 1 3)) <|folded-io> (1 . 3) <\unfolded-io|Scheme] > (\<#5206\>\<#5B50\> \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\>) <|unfolded-io> 1 <\unfolded-io|Scheme] > (\<#5206\>\<#6BCD\> \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\>) <|unfolded-io> 2 <\unfolded-io|Scheme] > (\<#5206\>\<#5F0F\>\<#663E\> \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\>) <|unfolded-io> > <\unfolded-io|Scheme] > (\<#5206\>\<#5F0F\>\<#663E\> \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\>) <|unfolded-io> > <\input|Scheme] > \; <\itemize> \<#6784\>\<#9020\>\<#51FD\>\<#6570\>\<#FF1A\>\<#5206\>\<#5F0F\> \<#9009\>\<#62E9\>\<#51FD\>\<#6570\>\<#FF1A\>\<#5206\>\<#5B50\>\<#3001\>\<#5206\>\<#6BCD\> \<#663E\>\<#793A\>\<#51FD\>\<#6570\>\<#FF1A\>\<#5206\>\<#5F0F\>\<#663E\> \<#FF08\>\<#548C\>\<#4EBA\>\<#7C7B\>\<#505A\>\<#4EA4\>\<#4E92\>\<#FF09\> <\slide> \<#7406\>\<#6570\>\<#7684\>\<#7B97\>\<#672F\>\<#8FD0\>\<#7B97\>> <\with|par-columns|2> <\session|scheme|default> <\unfolded-io|Scheme] > (\<#5206\>\<#5F0F\>\<#663E\> (\<#5206\>\<#5F0F\>\<#52A0\> \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\> \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\>)) <|unfolded-io> > <\unfolded-io|Scheme] > (\<#5206\>\<#5F0F\>\<#663E\> (\<#5206\>\<#5F0F\>\<#51CF\> \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\> \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\>)) <|unfolded-io> > <\unfolded-io|Scheme] > (\<#5206\>\<#5F0F\>\<#663E\> (\<#5206\>\<#5F0F\>\<#4E58\> \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\> \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\>)) <|unfolded-io> > <\unfolded-io|Scheme] > (\<#5206\>\<#5F0F\>\<#663E\> (\<#5206\>\<#5F0F\>\<#9664\> \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\> \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\>)) <|unfolded-io> > <\input|Scheme] > \; \<#7B97\>\<#672F\>\<#8FD0\>\<#7B97\>\<#51FD\>\<#6570\>\<#FF1A\>\<#5206\>\<#5F0F\>\<#52A0\>,\<#5206\>\<#5F0F\>\<#51CF\>,\<#5206\>\<#5F0F\>\<#4E58\>,\<#5206\>\<#5F0F\>\<#9664\> <\slide> \<#5F0F\>\<#52A0\>> <\equation*> |d>+>|d>=*d+n*d|d*d> <\session|scheme|default> <\unfolded-io|Scheme] > (define (\<#5206\>\<#5F0F\>\<#52A0\> x y) \ \ (let* ((n1 (\<#5206\>\<#5B50\> x)) \ \ \ \ \ \ \ \ \ (d1 (\<#5206\>\<#6BCD\> x)) \ \ \ \ \ \ \ \ \ (n2 (\<#5206\>\<#5B50\> y)) \ \ \ \ \ \ \ \ \ (d2 (\<#5206\>\<#6BCD\> y))) \ \ \ \ (\<#5206\>\<#5F0F\> (+ (* n1 d2) (* n2 d1)) \ \ \ \ \ \ \ \ \ \ (* d1 d2)))) <|unfolded-io> \<#5206\>\<#5F0F\>\<#52A0\> <\folded-io|Scheme] > (\<#5206\>\<#5F0F\>\<#663E\> (\<#5206\>\<#5F0F\>\<#52A0\> (\<#5206\>\<#5F0F\> 1 2) (\<#5206\>\<#5F0F\> 1 4))) <|folded-io> > <\input|Scheme] > \; <\slide> \<#8C61\>\<#5C42\>\<#7EA7\>> \<#63A5\>\<#53E3\>\<#4E0E\>\<#5B9E\>\<#73B0\>\<#7684\>\<#9694\>\<#79BB\>> <\itemize> \<#6709\>\<#7406\>\<#6570\>\<#7684\>\<#4F7F\>\<#7528\>\<#8005\> <\itemize> \<#6709\>\<#7406\>\<#6570\>\<#7684\>\<#7B97\>\<#672F\>\<#8FD0\>\<#7B97\> \<#FF08\>\<#6237\>\<#81EA\>\<#5B9A\>\<#4E49\>\<#7684\>\<#7B97\>\<#672F\>\<#8FD0\>\<#7B97\>>\<#FF09\> <\itemize> \<#6709\>\<#7406\>\<#6570\>\<#7684\>\<#6784\>\<#9020\>\<#4E0E\>\<#9009\>\<#62E9\> \<#FF08\>\<#6237\>\<#81EA\>\<#5B9A\>\<#4E49\>\<#7684\>\<#6570\>\<#636E\>\<#7ED3\>\<#6784\>>\<#FF09\> <\itemize> \<#6709\>\<#5E8F\>\<#5BF9\> pair \<#FF08\>\<#6237\>\<#81EA\>\<#5B9A\>\<#4E49\>\<#7684\>\<#6570\>\<#636E\>\<#7ED3\>\<#6784\>>\<#FF09\> <\itemize> \<#57FA\>\<#7840\>\<#6570\>\<#636E\>\<#7ED3\>\<#6784\>\<#FF1A\>\<#94FE\>\<#8868\>\<#FF08\>\<#8A00\>\<#5B9A\>\<#4E49\>>\<#FF09\> <\itemize> <\itemize> \<#5185\>\<#5B58\>\<#3001\>\<#5BC4\>\<#5B58\>\<#5668\>\<#3001\>\<#6307\>\<#4EE4\>\<#4E2D\>\<#7684\>\<#5B9E\>\<#73B0\>\<#FF08\>\<#91CA\>\<#5668\>>\<#FF09\> <\itemize> \<#86CB\>\<#631E\>\<#FF08\>\<#4E0D\>\<#7528\>\<#7BA1\>\<#73B0\>\<#6709\>\<#9E21\>\<#8FD8\>\<#662F\>\<#5148\>\<#6709\>\<#86CB\>\<#FF09\> <\itemize> \<#9E21\>\<#3001\>\<#86CB\> \; <\slide> \<#5E8F\>\<#5BF9\>\<#7684\>\<#62BD\>\<#8C61\>> <\description> \<#6784\>\<#9020\>\<#5668\>\<#FF1A\>\<#63D0\>\<#4F9B\>\<#4E24\>\<#4E2A\>\<#53C2\>\<#6570\>\<#FF0C\>\<#6784\>\<#9020\>\<#4E00\>\<#4E2A\>\<#6709\>\<#5E8F\>\<#5BF9\> \<#9009\>\<#62E9\>\<#5668\>\<#FF1A\>\<#6709\>\<#5E8F\>\<#5BF9\>\<#4E2D\>\<#7684\>\<#7B2C\>\<#4E00\>\<#4E2A\>\<#5143\>\<#7D20\> \<#9009\>\<#62E9\>\<#5668\>\<#FF1A\>\<#6709\>\<#5E8F\>\<#5BF9\>\<#4E2D\>\<#7684\>\<#7B2C\>\<#4E8C\>\<#4E2A\>\<#5143\>\<#7D20\> <\session|scheme|default> <\folded-io|Scheme] > (define (pair x1 x2) (cons x1 x2)) <|folded-io> pair <\folded-io|Scheme] > (define (pair.x1 p) (car p)) <|folded-io> pair.x1 <\folded-io|Scheme] > (define (pair.x2 p) (cdr p)) <|folded-io> pair.x2 <\folded-io|Scheme] > (pair 1 2) <|folded-io> (1 . 2) <\folded-io|Scheme] > (pair.x1 (pair 3 4)) <|folded-io> 3 <\folded-io|Scheme] > (pair.x2 (pair "\<#7236\>\<#4EB2\>" "\<#6BCD\>\<#4EB2\>")) <|folded-io> \<#6BCD\>\<#4EB2\> <\input|Scheme] > \; <\slide> \<#7840\>\<#6570\>\<#636E\>\<#7ED3\>\<#6784\>\<#FF1A\>\<#94FE\>\<#8868\>> <\description> \<#6784\>\<#9020\>\<#5668\>\<#FF1A\>\<#8868\>\<#793A\>\<#7A7A\>\<#94FE\>\<#8868\> \<#6784\>\<#9020\>\<#5668\>\<#FF1A\>\<#63D0\>\<#4F9B\>\<#4E00\>\<#4E2A\>\<#5143\>\<#7D20\>\<#548C\>\<#4E00\>\<#4E2A\>\<#94FE\>\<#8868\>\<#FF0C\>\<#5C06\>\<#4E24\>\<#8005\>\<#7EC4\>\<#5408\>\<#6210\>\<#94FE\>\<#8868\>\<#3002\> \<#9009\>\<#62E9\>\<#5668\>\<#FF1A\>\<#53D6\>\<#51FA\>\<#94FE\>\<#8868\>\<#5934\>\<#90E8\>\<#7684\>\<#5143\>\<#7D20\>\<#3002\> \<#9009\>\<#62E9\>\<#5668\>\<#FF1A\>\<#79FB\>\<#9664\>\<#94FE\>\<#8868\>\<#5934\>\<#90E8\>\<#4E4B\>\<#540E\>\<#FF0C\>\<#5269\>\<#4E0B\>\<#7684\>\<#5143\>\<#7D20\>\<#6309\>\<#7167\>\<#539F\>\<#6765\>\<#7684\>\<#987A\>\<#5E8F\>\<#7EC4\>\<#5408\>\<#6210\>\<#7684\>\<#94FE\>\<#8868\>\<#3002\> \<#6784\>\<#9020\>\<#5668\>\<#FF1A\>\<#63D0\>\<#4F9B\>\<#4E00\>\<#7EC4\>\<#5143\>\<#7D20\>\<#FF0C\>\<#53EF\>\<#4EE5\>\<#5C06\>\<#8FD9\>\<#4E00\>\<#7EC4\>\<#5143\>\<#7D20\>\<#7EC4\>\<#5408\>\<#6210\>\<#94FE\>\<#8868\>\<#3002\> <\session|scheme|default> <\folded-io|Scheme] > (list 1 2 3 4) # (cons 1 (cons 2 (cons 3 (cons 4 ())))) <|folded-io> (1 2 3 4) <\folded-io|Scheme] > (car (list 1 2 3 4)) <|folded-io> 1 <\folded-io|Scheme] > (cdr (list 1 2 3 4)) <|folded-io> (2 3 4) <\folded-io|Scheme] > (car (list )) <|folded-io> <\folded-io|Scheme] > (eq? (list ) (list )) <|folded-io> #t <\input|Scheme] > \; <\slide> \<#4E49\>\<#6570\>\<#636E\>> \<#901A\>\<#8FC7\>\<#5B9A\>\<#4E49\>\<#4E00\>\<#7EC4\>\<#8F91\>\<#81EA\>\<#6D3D\>>\<#7684\>\<#9009\>\<#62E9\>\<#51FD\>\<#6570\>\<#548C\>\<#6784\>\<#9020\>\<#51FD\>\<#6570\>\<#FF0C\>\<#5B9A\>\<#4E49\>\<#6570\>\<#636E\>\<#3002\> \<#6BD4\>\<#5982\>\<#81EA\>\<#7136\>\<#6570\>\<#516C\>\<#7406\>\<#FF1A\> <\axiom> \>. <\axiom> \<#82E5\>\>\<#FF0C\>\<#5219\>\<#6709\>\<#4E14\>\<#53EA\>\<#6709\>\<#4E00\>\<#4E2A\>\<#540E\>\<#7EE7\>>\\>. <\axiom> \<#5BF9\>\<#4EFB\>\<#610F\>\,x>\0>. <\axiom> \<#5BF9\>\<#4EFB\>\<#610F\>,x\\>\<#FF0C\>\<#82E5\>\x>\<#FF0C\>\<#5219\>>\x>>. <\axiom> \<#8BBE\>\\>. \<#82E5\>\>\<#FF0C\>\<#4E14\>\<#5F53\>\>\<#65F6\>\<#4E5F\>\<#6709\>>\\>\<#FF0C\>\<#5219\>=\>. <\slide> \<#4E49\>\<#81EA\>\<#7136\>\<#6570\>\<#8FD9\>\<#79CD\>\<#6570\>\<#636E\>> <\session|scheme|default> <\unfolded-io|Scheme] > (define \<#96F6\> (list )) <|unfolded-io> () <\unfolded-io|Scheme] > (define (\<#540E\>\<#7EE7\> x) (cons (list ) x))\ <|unfolded-io> \<#540E\>\<#7EE7\> <\unfolded-io|Scheme] > (\<#540E\>\<#7EE7\> \<#96F6\>) <|unfolded-io> (()) <\unfolded-io|Scheme] > (\<#540E\>\<#7EE7\> (\<#540E\>\<#7EE7\> \<#96F6\>)) <|unfolded-io> (() ()) <\unfolded-io|Scheme] > (\<#540E\>\<#7EE7\> (\<#540E\>\<#7EE7\> (\<#540E\>\<#7EE7\> \<#96F6\>))) <|unfolded-io> (() () ()) <\input|Scheme] > \; <\slide> \<#5176\>\<#4E2D\>\<#4E00\>\<#79CD\>\<#5B9E\>\<#73B0\>> <\session|scheme|default> <\folded-io|Scheme] > (define (cons2 x y) \ \ (define (dispatch m) \ \ \ \ (cond ((= m 0) x) \ \ \ \ \ \ \ \ \ \ ((= m 1) y) \ \ \ \ \ \ \ \ \ \ (else (error "Argument not 0 or 1 -- CONS" m)))) \ \ dispatch) <|folded-io> cons2 <\folded-io|Scheme] > (define (car2 z) (z 0)) <|folded-io> car2 <\folded-io|Scheme] > (define (cdr2 z) (z 1)) <|folded-io> cdr2 <\folded-io|Scheme] > (car2 (cons2 1 2)) <|folded-io> 1 <\folded-io|Scheme] > (cdr2 (cons2 1 2)) <|folded-io> 2 <\folded-io|Scheme] > (car2 (cons2 1 (cons2 2 (cons2 3 ())))) <|folded-io> 1 <\folded-io|Scheme] > (car2 (cdr2 (cons2 1 (cons2 2 (cons2 3 ()))))) <|folded-io> 2 <\input|Scheme] > \; <\slide> \<#7ED3\>> <\itemize> \<#4E3A\>\<#4EC0\>\<#4E48\>\<#9700\>\<#8981\>\<#62BD\>\<#8C61\>\<#5C42\>\<#7EA7\> \<#5982\>\<#4F55\>\<#5B9A\>\<#4E49\>\<#6570\>\<#636E\> Schem\<#539F\>\<#8BED\> (R7RS small) <\itemize> \<#94FE\>\<#8868\> <\itemize> \<#6709\>\<#5E8F\>\<#5BF9\> <\itemize> \<#5206\>\<#5F0F\> <\itemize> \<#6709\>\<#7406\>\<#6570\> <\initial> <\collection> <\references> <\collection> > > > > >