diff --git a/SICP/slide05.tm b/SICP/slide05.tm index 1eccd16..7cea01d 100644 --- a/SICP/slide05.tm +++ b/SICP/slide05.tm @@ -7,116 +7,306 @@ >>> - - \<#57FA\>\<#7840\>SICP\<#FF1A\>\<#7B2C\>5\<#8BFE\>> + <\slideshow> + <\slide> + \<#57FA\>\<#7840\>SICP\<#FF1A\>\<#7B2C\>5\<#8BFE\>> - <\wide-tabular> - || - - \<#7F16\>\<#7A0B\>\<#7684\>\<#57FA\>\<#672C\>\<#539F\>\<#7406\> - > - |<\cell> - - Elements of Programming - > - >| - \<#8868\>\<#8FBE\>\<#5F0F\> - |<\cell> - Expressions - >| - \<#547D\>\<#540D\>\<#4E0E\>\<#73AF\>\<#5883\> - |<\cell> - Naming and the Evironment - >| - \<#7EC4\>\<#5408\>\<#5F0F\>\<#7684\>\<#6C42\>\<#503C\> - |<\cell> - Evaluating Combinations - >| - \<#590D\>\<#5408\>\<#51FD\>\<#6570\> - |<\cell> - Compound Procedures - >| - \<#51FD\>\<#6570\>\<#5E94\>\<#7528\>\<#7684\>\<#4EE3\>\<#6362\>\<#6A21\>\<#578B\> - |<\cell> - The Subsitution Model for Procedure Application - >| - \<#6761\>\<#4EF6\>\<#8868\>\<#8FBE\>\<#5F0F\>\<#548C\>\<#8C13\>\<#8BCD\> - |<\cell> - Conditional Expressions and Predicates - >| - \; - |<\cell> - \; - >| - \<#7EBF\>\<#6027\>\<#9012\>\<#5F52\>\<#548C\>\<#8FED\>\<#4EE3\> - |<\cell> - Linear Recursion and Iteration - >| - \<#6811\>\<#5F62\>\<#9012\>\<#5F52\> - |<\cell> - Tree Recursion - >| - \<#589E\>\<#957F\>\<#7684\>\<#9636\> - |<\cell> - Orders of Growth - >| - \<#6C42\>\<#5E42\> - |<\cell> - Exponentiation - >| - \<#6700\>\<#5927\>\<#516C\>\<#7EA6\>\<#6570\> - |<\cell> - Greatest Common Divisors - >>> - - |<\hidden> - \<#8BED\>\<#56DE\>\<#987E\>> + <\wide-tabular> + || + + \<#7F16\>\<#7A0B\>\<#7684\>\<#57FA\>\<#672C\>\<#539F\>\<#7406\> + > + |<\cell> + + Elements of Programming + > + >| + \<#7EBF\>\<#6027\>\<#9012\>\<#5F52\>\<#548C\>\<#8FED\>\<#4EE3\> + |<\cell> + Linear Recursion and Iteration + >| + \<#6811\>\<#5F62\>\<#9012\>\<#5F52\> + |<\cell> + Tree Recursion + >| + \<#589E\>\<#957F\>\<#7684\>\<#9636\> + |<\cell> + Orders of Growth + >| + \<#6C42\>\<#5E42\> + |<\cell> + Exponentiation + >| + \<#6700\>\<#5927\>\<#516C\>\<#7EA6\>\<#6570\> + |<\cell> + Greatest Common Divisors + >>> + + - <\itemize> - \<#5E94\>\<#7528\>\<#4E00\>\<#4E2A\>\<#51FD\>\<#6570\>\<#7684\>\<#4EE3\>\<#6362\>\<#6A21\>\<#578B\>\<#FF1A\> + <\slide> + \<#8BED\>\<#56DE\>\<#987E\>> <\itemize> - \<#5E94\>\<#7528\>\<#5E8F\>\<#6C42\>\<#503C\> + \<#5E94\>\<#7528\>\<#4E00\>\<#4E2A\>\<#51FD\>\<#6570\>\<#7684\>\<#4EE3\>\<#6362\>\<#6A21\>\<#578B\>\<#FF1A\> - \<#6B63\>\<#5219\>\<#5E8F\>\<#6C42\>\<#503C\> + <\itemize> + \<#5E94\>\<#7528\>\<#5E8F\>\<#6C42\>\<#503C\> + + \<#6B63\>\<#5219\>\<#5E8F\>\<#6C42\>\<#503C\> + + + \<#9012\>\<#5F52\>\<#7684\>\<#8BA1\>\<#7B97\>\<#8FC7\>\<#7A0B\> + + \<#8FED\>\<#4EE3\>\<#7684\>\<#8BA1\>\<#7B97\>\<#8FC7\>\<#7A0B\> + + \<#9012\>\<#5F52\>\<#51FD\>\<#6570\>\<#7684\>\<#8BA1\>\<#7B97\>\<#8FC7\>\<#7A0B\>\<#4E0D\>\<#4E00\>\<#5B9A\>\<#662F\>\<#9012\>\<#5F52\>\<#7684\>\<#FF0C\>\<#4E5F\>\<#6709\>\<#53EF\>\<#80FD\>\<#662F\>\<#8FED\>\<#4EE3\>\<#7684\>\<#3002\> - \<#9012\>\<#5F52\>\<#7684\>\<#8BA1\>\<#7B97\>\<#8FC7\>\<#7A0B\> + \; - \<#8FED\>\<#4EE3\>\<#7684\>\<#8BA1\>\<#7B97\>\<#8FC7\>\<#7A0B\> + <\quote-env> + \<#4E4E\>\<#7528\>\<#6237\>\<#9AD8\>\<#82F1\>\<#607A\>|https://www.zhihu.com/question/21056295/answer/17030255>\<#FF1A\> - \<#9012\>\<#5F52\>\<#51FD\>\<#6570\>\<#7684\>\<#8BA1\>\<#7B97\>\<#8FC7\>\<#7A0B\>\<#4E0D\>\<#4E00\>\<#5B9A\>\<#662F\>\<#9012\>\<#5F52\>\<#7684\>\<#FF0C\>\<#4E5F\>\<#6709\>\<#53EF\>\<#80FD\>\<#662F\>\<#8FED\>\<#4EE3\>\<#7684\>\<#3002\> - + \<#6B63\>\<#5219\>\<#7684\>\<#82F1\>\<#8BED\>\<#539F\>\<#6587\>\<#662F\>regular\<#FF0C\>\<#53EF\>\<#4EE5\>\<#7406\>\<#89E3\>\<#4E3A\>\<#6709\>\<#89C4\>\<#5F8B\>\<#7684\>\<#FF0C\>\<#6709\>\<#89C4\>\<#5219\>\<#7684\>\<#3002\>\<#5728\>\<#82F1\>\<#8BED\>\<#91CC\>\<#9762\>\<#88AB\>\<#63CF\>\<#8FF0\>\<#4E3A\>regular\<#7684\>\<#5BF9\>\<#8C61\>\<#5176\>\<#5B9E\>\<#662F\>\<#6BD4\>\<#8F83\>\<#7B80\>\<#5355\>\<#7684\>\<#FF0C\>\<#5BB9\>\<#6613\>\<#638C\>\<#63E1\>\<#7684\>\<#5BF9\>\<#8C61\>\<#3002\>\<#6BD4\>\<#5982\>\<#8BF4\>\<#6B63\>\<#5219\>\<#8BED\>\<#8A00\>\<#53EA\>\<#6709\>\<#51E0\>\<#6761\>\<#7B80\>\<#5355\>\<#7684\>\<#5B9A\>\<#4E49\>\<#FF0C\>\<#9664\>\<#4E86\>\<#539F\>\<#5B50\>\<#FF08\>atom\<#FF09\>\<#7684\>\<#5B9A\>\<#4E49\>\<#5C31\>\<#662F\>\<#5404\>\<#79CD\>\<#8FDE\>\<#63A5\>\<#FF08\>concatenation\<#FF09\>\<#548C\>\<#6C42\>\<#5E76\>\<#FF08\>union\<#FF09\>\<#FF0C\>\<#5E76\>\<#4E14\>\<#53EF\>\<#4EE5\>\<#7B80\>\<#5355\>\<#7684\>\<#7528\>\<#786E\>\<#5B9A\>\<#72B6\>\<#6001\>\<#6709\>\<#9650\>\<#81EA\>\<#52A8\>\<#673A\>\<#8868\>\<#8FBE\>\<#FF1B\>\<#76F8\>\<#5BF9\>\<#800C\>\<#8A00\>\<#FF0C\>\<#4E0A\>\<#4E0B\>\<#6587\>\<#65E0\>\<#5173\>\<#4EE5\>\<#53CA\>\<#4E0A\>\<#4E0B\>\<#6587\>\<#76F8\>\<#5173\>\<#8BED\>\<#8A00\>\<#5C31\>\<#8981\>\<#590D\>\<#6742\>\<#7684\>\<#591A\>\<#4E86\>\<#FF0C\>\<#9700\>\<#8981\>\<#4E0B\>\<#63A8\>\<#81EA\>\<#52A8\>\<#673A\>\<#548C\>\<#7EBF\>\<#6027\>\<#6709\>\<#9650\>\<#81EA\>\<#52A8\>\<#673A\>\<#6765\>\<#8868\>\<#793A\>\<#4E86\>\<#3002\> + + - \; + <\slide> + \<#957F\>\<#7684\>\<#9636\>\V>\<#8BB0\>\<#6CD5\>> - <\quote-env> - \<#4E4E\>\<#7528\>\<#6237\>\<#9AD8\>\<#82F1\>\<#607A\>|https://www.zhihu.com/question/21056295/answer/17030255>\<#FF1A\> + <\definition> + \<#4EE4\>n\<#662F\>\<#4E00\>\<#4E2A\>\<#53C2\>\<#6570\>\<#FF0C\>\<#4F5C\>\<#4E3A\>\<#95EE\>\<#9898\>\<#89C4\>\<#6A21\>\<#7684\>\<#4E00\>\<#79CD\>\<#5EA6\>\<#91CF\>\<#FF0C\>\<#4EE4\>>\<#662F\>\<#4E00\>\<#4E2A\>\<#8BA1\>\<#7B97\>\<#8FC7\>\<#7A0B\>\<#5728\>\<#5904\>\<#7406\>\<#89C4\>\<#6A21\>\<#4E3A\>n\<#7684\>\<#95EE\>\<#9898\>\<#6240\>\<#9700\>\<#8981\>\<#7684\>\<#8D44\>\<#6E90\>\<#91CF\>\<#3002\>\<#5982\>\<#679C\>\<#5B58\>\<#5728\>\<#4E0E\>\<#65E0\>\<#5173\>\<#7684\>\<#6574\>\<#6570\>>\<#548C\>>\<#FF0C\>\<#4F7F\>\<#5F97\> - \<#6B63\>\<#5219\>\<#7684\>\<#82F1\>\<#8BED\>\<#539F\>\<#6587\>\<#662F\>regular\<#FF0C\>\<#53EF\>\<#4EE5\>\<#7406\>\<#89E3\>\<#4E3A\>\<#6709\>\<#89C4\>\<#5F8B\>\<#7684\>\<#FF0C\>\<#6709\>\<#89C4\>\<#5219\>\<#7684\>\<#3002\>\<#5728\>\<#82F1\>\<#8BED\>\<#91CC\>\<#9762\>\<#88AB\>\<#63CF\>\<#8FF0\>\<#4E3A\>regular\<#7684\>\<#5BF9\>\<#8C61\>\<#5176\>\<#5B9E\>\<#662F\>\<#6BD4\>\<#8F83\>\<#7B80\>\<#5355\>\<#7684\>\<#FF0C\>\<#5BB9\>\<#6613\>\<#638C\>\<#63E1\>\<#7684\>\<#5BF9\>\<#8C61\>\<#3002\>\<#6BD4\>\<#5982\>\<#8BF4\>\<#6B63\>\<#5219\>\<#8BED\>\<#8A00\>\<#53EA\>\<#6709\>\<#51E0\>\<#6761\>\<#7B80\>\<#5355\>\<#7684\>\<#5B9A\>\<#4E49\>\<#FF0C\>\<#9664\>\<#4E86\>\<#539F\>\<#5B50\>\<#FF08\>atom\<#FF09\>\<#7684\>\<#5B9A\>\<#4E49\>\<#5C31\>\<#662F\>\<#5404\>\<#79CD\>\<#8FDE\>\<#63A5\>\<#FF08\>concatenation\<#FF09\>\<#548C\>\<#6C42\>\<#5E76\>\<#FF08\>union\<#FF09\>\<#FF0C\>\<#5E76\>\<#4E14\>\<#53EF\>\<#4EE5\>\<#7B80\>\<#5355\>\<#7684\>\<#7528\>\<#786E\>\<#5B9A\>\<#72B6\>\<#6001\>\<#6709\>\<#9650\>\<#81EA\>\<#52A8\>\<#673A\>\<#8868\>\<#8FBE\>\<#FF1B\>\<#76F8\>\<#5BF9\>\<#800C\>\<#8A00\>\<#FF0C\>\<#4E0A\>\<#4E0B\>\<#6587\>\<#65E0\>\<#5173\>\<#4EE5\>\<#53CA\>\<#4E0A\>\<#4E0B\>\<#6587\>\<#76F8\>\<#5173\>\<#8BED\>\<#8A00\>\<#5C31\>\<#8981\>\<#590D\>\<#6742\>\<#7684\>\<#591A\>\<#4E86\>\<#FF0C\>\<#9700\>\<#8981\>\<#4E0B\>\<#63A8\>\<#81EA\>\<#52A8\>\<#673A\>\<#548C\>\<#7EBF\>\<#6027\>\<#6709\>\<#9650\>\<#81EA\>\<#52A8\>\<#673A\>\<#6765\>\<#8868\>\<#793A\>\<#4E86\>\<#3002\> - - |<\hidden> - \<#957F\>\<#7684\>\<#9636\>\V>\<#8BB0\>\<#6CD5\>> + <\equation*> + k*f\R\k*f + - <\definition> - \<#4EE4\>n\<#662F\>\<#4E00\>\<#4E2A\>\<#53C2\>\<#6570\>\<#FF0C\>\<#4F5C\>\<#4E3A\>\<#95EE\>\<#9898\>\<#89C4\>\<#6A21\>\<#7684\>\<#4E00\>\<#79CD\>\<#5EA6\>\<#91CF\>\<#FF0C\>\<#4EE4\>>\<#662F\> - - |<\hidden> - \<#5E42\>\<#7684\>\<#65F6\>\<#7A7A\>\<#590D\>\<#6742\>\<#5EA6\>> + \<#5BF9\>\<#4EFB\>\<#4F55\>\<#8DB3\>\<#591F\>\<#5927\>\<#7684\>\<#503C\>\<#90FD\>\<#6210\>\<#7ACB\>\<#FF0C\>\<#6211\>\<#4EEC\>\<#79F0\>>\<#5177\>\<#6709\>|)>>\<#7684\>\<#957F\>\<#9636\>>\<#3002\> + - \; - |<\hidden> - \<#5927\>\<#516C\>\<#7EA6\>\<#6570\>> + <\example> + \<#67D0\>\<#67D0\>\<#7B97\>\<#6CD5\>\<#7684\>\<#65F6\>\<#95F4\>\<#590D\>\<#6742\>\<#5EA6\>\<#4E3A\>|)>> + - \; - > + <\equation*> + \<#7B97\>\<#8FC7\>\<#7A0B\>\<#6240\>\<#9700\>\<#7684\>\<#6B65\>\<#9AA4\>\<#6570\>>||\<#957F\>\<#9636\>>>|>||>|>|>||)>>>|+10*n+17>||>>>> + + + \; + + \; + + + <\slide> + \<#6CD5\>\<#5BFC\>\<#8BBA\>\<#5BF9\>>\<#8BB0\>\<#53F7\>\<#7684\>\<#5B9A\>\<#4E49\>> + + <\definition> + For a given function >, we denote by |)>> + + <\equation*> + \|)>=: + \c\0,c\0,n,\n\n,0\c*g\f\c*g|}> + + + + <\definition> + For a given function >, we denote the set of + funtions by |)>> + + <\equation*> + O|)>=:\c,n,\n\n,0\f\c*g|}> + + + + <\definition> + For a given function , we denote the set of fuctions by + |)>> + + <\equation*> + \|)>=:\c,n,\n\n,0\c*g\f|}> + + + + + <\slide> + \<#8868\>\<#7684\>\<#5B9A\>\<#4E49\>> + + |gr-frame|>|gr-geometry||gr-grid||gr-edit-grid-aspect|||>|gr-edit-grid||gr-arrow-end|\|gr-auto-crop|true|gr-grid-old||1>|gr-edit-grid-old||1>|gr-transformation||||>|magnify|0.840896415|gr-snap|||||>>||||>>|>|>||||>>||||>>||||>>|>|>|>||||>>|>||||>>||||>>|>||||>>||||>>||||>>||||>>||||>>||||>>||>>||>>||>>||>>||magnify|0.8408964147443614|line-width|2ln||>>||magnify|0.8408964147443614|line-width|2ln||>>||magnify|0.8408964147443614|line-width|2ln||>>||magnify|0.8408964147443614|line-width|2ln||>>||magnify|0.8408964147443614|line-width|2ln||>>||magnify|0.8408964147443614|line-width|2ln||>>||magnify|0.8408964147443614|line-width|2ln||>>||magnify|0.8408964147443614|line-width|2ln||>>||magnify|0.8408964147443614|line-width|2ln||>>>> + + <\scm-code> + (cons 1 (cons 2 (cons 3 (cons 4 ())))) + + + + + <\session|scheme|default> + <\unfolded-io|Scheme] > + () + <|unfolded-io> + () + + + <\unfolded-io|Scheme] > + (list 1 2 3 4) + <|unfolded-io> + (1 2 3 4) + + + <\unfolded-io|Scheme] > + (cons 0 (list 1 2 3 4 5)) + <|unfolded-io> + (0 1 2 3 4 5) + + + <\unfolded-io|Scheme] > + (cdr (list 1 2 3 4 5)) + <|unfolded-io> + (2 3 4 5) + + + <\input|Scheme] > + \; + + + + + <\slide> + \<#94FE\>\<#8868\>\<#957F\>\<#5EA6\>\<#7684\>\<#65F6\>\<#95F4\>\<#590D\>\<#6742\>\<#5EA6\>> + + <\session|scheme|default> + <\unfolded-io|Scheme] > + (eq? () (list )) + <|unfolded-io> + #t + + + <\unfolded-io|Scheme] > + (define (list-length l) + + \ \ (if (eq? () l) + + \ \ \ \ \ \ 0 + + \ \ \ \ \ \ (+ 1 (list-length (cdr l))))) + <|unfolded-io> + list-length + + + <\unfolded-io|Scheme] > + (list-length (list 1 2 3 4)) + <|unfolded-io> + 4 + + + <\unfolded-io|Scheme] > + (define (list-min l) + + \ \ (if (= (list-length l) 1) + + \ \ \ \ \ \ (car l) + + \ \ \ \ \ \ (min (car l) (list-min (cdr l))))) + <|unfolded-io> + list-min + + + <\input|Scheme] > + \; + + + + <\equation*> + \ + + + <\equation*> + O + + + + <\slide> + \<#7684\>\<#65F6\>\<#95F4\>\<#590D\>\<#6742\>\<#5EA6\>> + + <\session|scheme|default> + <\unfolded-io|Scheme] > + (define (range n) + + \ \ (define (range-iter k n) + + \ \ \ \ (if (= k n) + + \ \ \ \ \ \ \ \ (list n) + + \ \ \ \ \ \ \ \ (cons k (range-iter (+ k 1) n)))) + + \ \ (range-iter 1 n)) + <|unfolded-io> + range + + + <\unfolded-io|Scheme] > + (range 3) + <|unfolded-io> + (1 2 3) + + + <\input|Scheme] > + (define (range n) + + \ \ (append (range (- n 1) (list n)))) + + + + + <\slide> + \<#5E42\>> + + <\equation*> + b=b>|1>>|>|>>>> + + + \; + + + <\slide> + \<#5927\>\<#516C\>\<#7EA6\>\<#6570\>> + + <\session|scheme|default> + <\input> + Scheme]\ + <|input> + (define (gcd a b) + + \ \ (if (= b 0) + + \ \ \ \ \ \ a + + \ \ \ \ \ \ (gcd b (remainder a b)))) + + + + \<#8FD9\>\<#4E2A\>\<#4F8B\>\<#5B50\>\<#7684\>\<#7279\>\<#70B9\>\<#5728\>\<#4E8E\>\<#FF0C\>\<#6211\>\<#4EEC\>\<#4E0D\>\<#77E5\>\<#9053\>\<#6C42\>\<#4E24\>\<#4E2A\>\<#6570\>\<#7684\>\<#6700\>\<#5927\>\<#516C\>\<#7EA6\>\<#6570\>\<#FF0C\>\<#5230\>\<#5E95\>\<#9700\>\<#8981\>\<#51E0\>\<#4E2A\>\<#8FED\>\<#4EE3\>\<#6B65\>\<#9AA4\>\<#3002\> + + <\exercise> + \<#7ED3\>\<#5408\>\<#4E66\>\<#672C\>\<#4E0A\>\<#7684\>\<#8BB2\>\<#89E3\>\<#FF0C\>\<#81EA\>\<#5DF1\>\<#6574\>\<#7406\>\<#4E00\>\<#4E0B\>\<#6B27\>\<#51E0\>\<#91CC\>\<#5F97\>\<#7B97\>\<#6CD5\>\<#7684\>\<#589E\>\<#957F\>\<#9636\>\<#4E3A\>>\<#7684\>\<#8BC1\>\<#660E\>\<#3002\> + + + <\initial> <\collection> - + + + +