> <\body> <\hide-preamble> >>> \<#57FA\>\<#7840\>SICP\<#FF1A\>\<#7B2C\>3\<#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 >>> |<\hidden> \<#4EF6\>\<#8868\>\<#8FBE\>\<#5F0F\>\<#548C\>\<#8C13\>\<#8BCD\>\V\<#77ED\>\<#8DEF\>\<#8FD0\>\<#7B97\>> <\itemize> \<#5E94\>\<#7528\>\<#5E8F\>\<#6C42\>\<#503C\>\<#FF08\>Scheme\<#4F7F\>\<#7528\>\<#7684\>\<#662F\>\<#5E94\>\<#7528\>\<#5E8F\>\<#6C42\>\<#503C\>\<#FF09\> \<#6B63\>\<#5219\>\<#5E8F\>\<#6C42\>\<#503C\> \<#4F8B\>\<#5206\>\<#6790\>\<#FF1A\>\<#5B9E\>\<#73B0\>\<#6C42\>\<#7EDD\>\<#5BF9\>\<#503C\>\<#7684\>\<#591A\>\<#79CD\>\<#65B9\>\<#5F0F\>> <\with|par-columns|2> <\equation*> =||||>|0,>>||>|>||>|0.>>>>>|\> <\session|scheme|default> <\unfolded-io|Scheme] > (define (abs1 x) \ \ (cond ((\ x 0) x) \ \ \ \ \ \ \ \ ((= x 0) 0) \ \ \ \ \ \ \ \ (else (- x)))) <|unfolded-io> abs1 <\unfolded-io|Scheme] > (define (abs2 x) \ \ (if (\ x 0) \ \ \ \ \ \ x \ \ \ \ \ \ (- x))) <|unfolded-io> abs2 <\unfolded-io|Scheme] > (define (abs3 x) \ \ (or (and (\ x) x) (- x))) <|unfolded-io> abs3 <\unfolded-io|Scheme] > (abs1 1) <|unfolded-io> 1 <\unfolded-io|Scheme] > (abs1 -1) <|unfolded-io> 1 <\input|Scheme] > \; <\folded> <\question> \<#4E3A\>\<#4EC0\>\<#4E48\>\<#548C\>\<#662F\>\<#5FC5\>\<#987B\>\<#7684\>\<#FF1F\> <|folded> <\exercise> \<#4F7F\>\<#7528\>\<#5B9E\>\<#73B0\>\<#548C\>\<#3002\> \<#53C2\>\<#8003\>\<#6587\>\<#6863\>\<#FF1A\> \; |<\hidden> \<#73AF\>\<#FF1A\>\<#6C42\>\<#548C\>> \<#4F8B\>\<#5206\>\<#6790\>\<#FF1A\>\<#6C42\>\<#548C\>> <\with|par-columns|2> <\equation*> i=1+2+\+n \; <\render-code> result := 0 1 n|result := result + i> <\with|par-columns|2> <\session|scheme|default> <\folded-io|Scheme] > (define result 0) <|folded-io> 0 <\input|Scheme] > (for (x (list 1 2 3 4)) \ \ (set! result (+ result x))) <\folded-io|Scheme] > result <|folded-io> 10 <\input|Scheme] > \; <\session|python|default> <\input> \\\\ <|input> def sum_n(n): \ \ \ \ result= 0 \ \ \ \ for i in range(n): \ \ \ \ \ \ \ \ result= result + (i + 1) \ \ \ \ return result <\folded-io> \\\\ <|folded-io> sum_n(3) <|folded-io> 6 <\folded-io> \\\\ <|folded-io> list(range(3)) <|folded-io> [0, 1, 2] <\input> \\\\ <|input> \; <\exercise> \<#4F7F\>\<#7528\>Scheme\<#5B9E\>\<#73B0\>range\<#3002\> |<\hidden> \<#6027\>\<#9012\>\<#5F52\>\<#FF1A\>\<#6C42\>\<#548C\>> <\session|scheme|default> <\unfolded-io|Scheme] > (define (sum start end) \ \ (cond ((\ start end) 0) \ \ \ \ \ \ \ \ ((= start end) end) \ \ \ \ \ \ \ \ (else (+ start (sum (+ start 1) end))))) \; <|unfolded-io> sum <\unfolded-io|Scheme] > (sum 2 3) <|unfolded-io> 5 <\input|Scheme] > \; <\with|par-columns|2|par-left|1fn|par-right|4fn|par-columns-sep|0fn> <\eqnarray*> i>||i>>|||i|)>>>|||i|)>|)>>>|||>>|||+i|)>|)>>>>|||+|)>|)>>>|||+|)>|)>>>|||>>|||>|||>>> \; |<\hidden> \<#5F62\>\<#9012\>\<#5F52\>\<#FF1A\>\<#6590\>\<#6CE2\>\<#90A3\>\<#5951\>\<#6570\>\<#5217\>> <\folded> <\equation*> =||| n=0,>>|| n=1,>>|+>|.>>>>>|\> <|folded> |>>||>>||>>> > <\session|scheme|default> <\folded-io|Scheme] > (define (fib n) \ \ (cond ((= n 0) 0) \ \ \ \ \ \ \ \ ((= n 1) 1) \ \ \ \ \ \ \ \ (else (+ (fib (- n 1)) (fib (- n 2)))))) <|folded-io> fib <\folded-io|Scheme] > (fib 2) <|folded-io> 1 <\input|Scheme] > \; |<\hidden> \<#5F62\>\<#9012\>\<#5F52\>\\<#8FED\>\<#4EE3\>> <\equation*> =||| n=0,>>|| n=1,>>|+>|.>>>>>|\> <\equation*> ||||||>|||>|||||||>|>|>|+f>>|=0>|=1>||||||||>||=1>|=2>|||||||>|||=2>|=3>||||||>||||=b>|=a+b>|||||>>>> <\with|par-columns|2> <\algorithm> <\math> a\ 0 b \ 1 <\algo-for|i \ 1 n> a \ b b \ a + b b <\algorithm> a \ 0 b > 1 <\algo-for|i \ 1 n> old_b \ b b \ a + b a \ old_b b \; |<\hidden> \<#6CBB\>\<#6CD5\>\<#FF1A\>\<#627E\>\<#96F6\>\<#95EE\>\<#9898\>> <\itemize> \<#65E0\>\<#9650\>\<#591A\>\<#4E00\>\<#5143\>\<#7EB8\>\<#5E01\> \<#65E0\>\<#9650\>\<#591A\>\<#4E94\>\<#5143\>\<#7EB8\>\<#5E01\> \<#65E0\>\<#9650\>\<#591A\>\<#5341\>\<#5143\>\<#7EB8\>\<#5E01\> \<#65E0\>\<#9650\>\<#591A\>\<#4E94\>\<#5341\>\<#5143\>\<#7EB8\>\<#5E01\> <\folded-documentation> <\question> \6\<#6709\>\<#51E0\>\<#79CD\>\<#627E\>\<#96F6\>\<#65B9\>\<#5F0F\>\<#FF1F\> <|folded-documentation> \6=6\\1, \6=1\\5+1 <\folded-documentation> <\question> \16\<#6709\>\<#51E0\>\<#79CD\>\<#627E\>\<#96F6\>\<#65B9\>\<#5F0F\>\<#FF1F\> <|folded-documentation> \; <\folded-documentation> <\question> \<#5BF9\>\<#4E8E\>\n\<#FF0C\>\<#4E00\>\<#5171\>\<#6709\>\<#591A\>\<#5C11\>\<#79CD\>\<#627E\>\<#96F6\>\<#65B9\>\<#5F0F\>\<#FF1F\> <|folded-documentation> <\equation*> f|)>=f|)>+f|)>+f|)>+f|)>+f|)>+f|)>+f|)>+f|)>+f|)>+f|)>+f|)>+f|)>+f|)>+f|)> <\equation*> f|)>=f|)>+f|)> |<\hidden> \<#7ED3\>> <\itemize> \<#56DE\>\<#987E\>\<#5E94\>\<#7528\>\<#5E8F\>\<#6C42\>\<#503C\>\<#548C\>\<#6B63\>\<#5219\>\<#5E8F\>\<#6C42\>\<#503C\> \<#6DF1\>\<#5165\>\<#7406\>\<#89E3\>\<#548C\> \<#7F16\>\<#7A0B\>\<#4E2D\>\<#6700\>\<#57FA\>\<#7840\>\<#7684\>\<#6982\>\<#5FF5\>\<#4E4B\>\<#4E00\>\<#FF1A\>\<#5FAA\>\<#73AF\> \<#4F7F\>\<#7528\>\<#9012\>\<#5F52\>\<#5B9E\>\<#73B0\>\<#5FAA\>\<#73AF\>\<#FF0C\>\<#57FA\>\<#4E8E\>\<#5FAA\>\<#73AF\>\<#7406\>\<#89E3\>\<#9012\>\<#5F52\> \<#5B9E\>\<#6218\>\<#FF1A\>\<#7EBF\>\<#6027\>\<#9012\>\<#5F52\>\<#548C\>\<#6811\>\<#5F62\>\<#9012\>\<#5F52\> \<#6280\>\<#5DE7\>\<#FF1A\>\<#5C06\>\<#9012\>\<#5F52\>\<#5B9E\>\<#73B0\>\<#6539\>\<#4E3A\>\<#8FED\>\<#4EE3\>\<#5B9E\>\<#73B0\> \<#62BD\>\<#8C61\>\<#FF1A\>\<#5229\>\<#7528\>\<#9012\>\<#5F52\>\<#89E3\>\<#51B3\>\<#73B0\>\<#5B9E\>\<#4E2D\>\<#7684\>\<#627E\>\<#96F6\>\<#95EE\>\<#9898\> > <\initial> <\collection> <\references> <\collection> > > <\auxiliary> <\collection> <\associate|toc> |\<#6848\>\<#4F8B\>\<#5206\>\<#6790\>\<#FF1A\>\<#5B9E\>\<#73B0\>\<#6C42\>\<#7EDD\>\<#5BF9\>\<#503C\>\<#7684\>\<#591A\>\<#79CD\>\<#65B9\>\<#5F0F\> |.>>>>|> > |\<#6848\>\<#4F8B\>\<#5206\>\<#6790\>\<#FF1A\>\<#6C42\>\<#548C\> |.>>>>|> >