diff --git a/SICP/code08.tm b/SICP/code08.tm new file mode 100644 index 0000000..146cdd7 --- /dev/null +++ b/SICP/code08.tm @@ -0,0 +1,383 @@ + + +> + +<\body> + <\session|scheme|default> + <\unfolded-io|Scheme] > + (define (make-rat n d) (cons n d)) + <|unfolded-io> + make-rat + + + <\unfolded-io|Scheme] > + (define (numer x) (car x)) + <|unfolded-io> + numer + + + <\unfolded-io|Scheme] > + (define (denom x) (cdr x)) + <|unfolded-io> + denom + + + <\unfolded-io|Scheme] > + (define (\<#5206\>\<#5F0F\> n d) (make-rat n d)) + <|unfolded-io> + \<#5206\>\<#5F0F\> + + + <\unfolded-io|Scheme] > + (define (\<#5206\>\<#5B50\> x) (numer x)) + <|unfolded-io> + \<#5206\>\<#5B50\> + + + <\unfolded-io|Scheme] > + (define (\<#5206\>\<#6BCD\> x) (denom x)) + <|unfolded-io> + \<#5206\>\<#6BCD\> + + + <\unfolded-io|Scheme] > + (kbd-map ("f z var" (insert (utf8-\cork "\<#5206\>\<#5B50\>")))) + <|unfolded-io> + ("f z tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("f s var" (insert (utf8-\cork "\<#5206\>\<#5F0F\>")))) + <|unfolded-io> + ("f s tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("f m var" (insert (utf8-\cork "\<#5206\>\<#6BCD\>")))) + <|unfolded-io> + ("f m tab") + + + <\input|Scheme] > + \; + + + + <\session|scheme|default> + <\unfolded-io|Scheme] > + <\with|prog-scripts|scheme> + (define (add-rat x y) + + \ \ (make-rat (+ (* (numer x) (denom y)) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (* (numer y) (denom x))) + + \ \ \ \ \ \ \ \ \ \ \ \ (* (denom x) (denom y)))) + + <|unfolded-io> + add-rat + + + <\unfolded-io|Scheme] > + (define (sub-rat x y) + + \ \ (make-rat (- (* (numer x) (denom y)) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (* (numer y) (denom x))) + + \ \ \ \ \ \ \ \ \ \ \ \ (* (denom x) (denom y)))) + <|unfolded-io> + sub-rat + + + <\unfolded-io|Scheme] > + (define (mul-rat x y) + + \ \ (make-rat (* (numer x) (numer y)) + + \ \ \ \ \ \ \ \ \ \ \ \ (* (denom x) (denom y)))) + <|unfolded-io> + mul-rat + + + <\unfolded-io|Scheme] > + (define (div-rat x y) + + \ \ (make-rat (* (numer x) (denom y)) + + \ \ \ \ \ \ \ \ \ \ \ \ (* (denom x) (numer y)))) + <|unfolded-io> + div-rat + + + <\unfolded-io|Scheme] > + (define (equal-rat? x y) + + \ \ (= (* (numer x) (denom y)) + + \ \ \ \ \ (* (numer y) (denom x)))) + <|unfolded-io> + equal-rat? + + + <\unfolded-io|Scheme] > + (kbd-map ("f s + var" (insert (utf8-\cork + "\<#5206\>\<#5F0F\>\<#52A0\>")))) + <|unfolded-io> + ("f s + tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("f s - var" (insert (utf8-\cork + "\<#5206\>\<#5F0F\>\<#51CF\>")))) + <|unfolded-io> + ("f s - tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("f s * var" (insert (utf8-\cork + "\<#5206\>\<#5F0F\>\<#4E58\>")))) + <|unfolded-io> + ("f s * tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("f s / var" (insert (utf8-\cork + "\<#5206\>\<#5F0F\>\<#9664\>")))) + <|unfolded-io> + ("f s / tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("f s x var" (insert (utf8-\cork + "\<#5206\>\<#5F0F\>\<#663E\>")))) + <|unfolded-io> + ("f s x tab") + + + <\unfolded-io|Scheme] > + (define (\<#5206\>\<#5F0F\>\<#52A0\> x y) (add-rat x y)) + <|unfolded-io> + \<#5206\>\<#5F0F\>\<#52A0\> + + + <\unfolded-io|Scheme] > + (define (\<#5206\>\<#5F0F\>\<#51CF\> x y) (sub-rat x y)) + <|unfolded-io> + \<#5206\>\<#5F0F\>\<#51CF\> + + + <\unfolded-io|Scheme] > + (define (\<#5206\>\<#5F0F\>\<#4E58\> x y) (mul-rat x y)) + <|unfolded-io> + \<#5206\>\<#5F0F\>\<#4E58\> + + + <\unfolded-io|Scheme] > + (define (\<#5206\>\<#5F0F\>\<#9664\> x y) (div-rat x y)) + <|unfolded-io> + \<#5206\>\<#5F0F\>\<#9664\> + + + <\input|Scheme] > + \; + + + + <\session|scheme|default> + <\unfolded-io|Scheme] > + (define x (cons 1 2)) + <|unfolded-io> + (1 . 2) + + + <\unfolded-io|Scheme] > + (car x) + <|unfolded-io> + 1 + + + <\unfolded-io|Scheme] > + (cdr x) + <|unfolded-io> + 2 + + + <\input|Scheme] > + \; + + + + <\session|scheme|default> + <\unfolded-io|Scheme] > + (define x (cons 1 2)) + <|unfolded-io> + (1 . 2) + + + <\unfolded-io|Scheme] > + (define y (cons 3 4)) + <|unfolded-io> + (3 . 4) + + + <\unfolded-io|Scheme] > + (define z (cons x y)) + <|unfolded-io> + ((1 . 2) 3 . 4) + + + <\unfolded-io|Scheme] > + (car (car z)) + <|unfolded-io> + 1 + + + <\input|Scheme] > + \; + + + + \; + + <\session|scheme|default> + <\input|Scheme] > + (define (print-rat x) + + \ \ (newline) + + \ \ (display (numer x)) + + \ \ (display "/") + + \ \ (display (denom x))) + + + <\unfolded-io|Scheme] > + (define (\<#5206\>\<#5F0F\>\<#663E\> x) + + \ \ (stree-\tree `(frac ,(\<#5206\>\<#5B50\> x) + ,(\<#5206\>\<#6BCD\> x)))) + <|unfolded-io> + \<#5206\>\<#5F0F\>\<#663E\> + + + <\input|Scheme] > + \; + + + + <\session|scheme|default> + <\unfolded-io|Scheme] > + (define \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\> (\<#5206\>\<#5F0F\> 1 2)) + <|unfolded-io> + (1 . 2) + + + <\unfolded-io|Scheme] > + (define \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\> (\<#5206\>\<#5F0F\> 1 3)) + <|unfolded-io> + (1 . 3) + + + <\unfolded-io|Scheme] > + (\<#5206\>\<#5F0F\>\<#663E\> \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\>) + <|unfolded-io> + > + + + <\unfolded-io|Scheme] > + (\<#5206\>\<#5F0F\>\<#663E\> \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\>) + <|unfolded-io> + > + + + <\folded-io|Scheme] > + (\<#5206\>\<#5F0F\>\<#663E\> (\<#5206\>\<#5F0F\>\<#52A0\> + \<#4E8C\>\<#5206\>\<#4E4B\>\<#4E00\> + \<#4E09\>\<#5206\>\<#4E4B\>\<#4E00\>)) + <|folded-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] > + \; + + + + <\session|scheme|default> + <\input> + Scheme]\ + <|input> + (define (make-rat n d) + + \ \ (let ((g (gcd n d))) + + \ \ \ \ (cons (/ n g) (/ d g)))) + + + + <\session|scheme|default> + <\input|Scheme] > + (print-rat (add-rat one-third one-third)) + + + <\input|Scheme] > + \; + + + + +<\initial> + <\collection> + + + + + +<\references> + <\collection> + > + > + > + + + +<\auxiliary> + <\collection> + <\associate|toc> + |2.1.1 |.>>>>|> + > + + |2.1.2 |.>>>>|> + > + + |2.1.3 |.>>>>|> + > + + + \ No newline at end of file diff --git a/SICP/index.tm b/SICP/index.tm index d23bf70..e189efa 100644 --- a/SICP/index.tm +++ b/SICP/index.tm @@ -24,6 +24,12 @@ \<#76EE\>\<#6807\>\<#90AE\>\<#7BB1\>\<#FF1A\>shenda AT ustc.edu + \<#7B2C\>8\<#8BFE\>\<#FF1A\>\<#6709\>\<#7406\>\<#6570\>\<#7684\>\<#6570\>\<#636E\>\<#62BD\>\<#8C61\> + + \<#8BFE\>\<#4EF6\>\<#FF1A\>\<#706F\>\<#7247\>08|slide08.tm> + + \<#4EE3\>\<#7801\>\<#FF1A\>\<#7801\>\<#6E05\>\<#5355\>08|code08.tm> + \<#7B2C\>7\<#8BFE\>\<#FF1A\>\<#9AD8\>\<#9636\>\<#51FD\>\<#6570\> \<#7EC3\>\<#4E60\>\<#FF1A\>\<#8BFE\>\<#540E\>\<#4E60\>\<#9898\>\<#7684\>\<#6570\>\<#5B66\>\<#542B\>\<#91CF\>\<#6BD4\>\<#8F83\>\<#91CD\>\<#FF0C\>\<#53EF\>\<#81EA\>\<#884C\>\<#9009\>\<#62E9\>\<#4E00\>\<#4E9B\>\<#4E60\>\<#9898\>\<#7EC3\>\<#4E60\>\<#4E00\>\<#4E0B\> diff --git a/SICP/slide08.tm b/SICP/slide08.tm new file mode 100644 index 0000000..a207f5e --- /dev/null +++ b/SICP/slide08.tm @@ -0,0 +1,546 @@ + + +> + +<\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> + > + > + > + > + > + + \ No newline at end of file