锘??xml version="1.0" encoding="utf-8" standalone="yes"?>色诱久久av,国产视频久久,国产美女久久久http://www.shnenglu.com/cuigang/category/5877.html鍐欏啓瀛楋紝鐪嬬湅涔︼紝鑱婅亰澶?/description>zh-cnTue, 12 Jul 2011 03:00:22 GMTTue, 12 Jul 2011 03:00:22 GMT60鎴戠殑SICP涔犻絳旀錛?.36~2.39錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/07/02/55084.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Tue, 01 Jul 2008 16:08:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/07/02/55084.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/55084.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/07/02/55084.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/55084.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/55084.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;"><span style="font-weight: bold;">2.36</span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define s (list (list </span><span style="color: #000000;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">3</span><span style="color: #000000;">)(list </span><span style="color: #000000;">4</span><span style="color: #000000;"> </span><span style="color: #000000;">5</span><span style="color: #000000;"> </span><span style="color: #000000;">6</span><span style="color: #000000;">)(list </span><span style="color: #000000;">7</span><span style="color: #000000;"> </span><span style="color: #000000;">8</span><span style="color: #000000;"> </span><span style="color: #000000;">9</span><span style="color: #000000;">)(list </span><span style="color: #000000;">10</span><span style="color: #000000;"> </span><span style="color: #000000;">11</span><span style="color: #000000;"> </span><span style="color: #000000;">12</span><span style="color: #000000;">)))<br>(define (accumulate-n op init seqs)<br>  (if (null? (car seqs)) null<br>      (cons (accumulate op init (map# (lambda(x) (car x)) seqs))<br>            (accumulate-n op init (map# (lambda(x) (cdr x)) seqs)))))</span></div> <br><span style="font-weight: bold;">2.38</span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008000;">;</span><span style="color: #008000;">> (fold-right / 1 (list 1 2 3))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">3/2</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">> (fold-left / 1 (list 1 2 3))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">1/6</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">> (fold-right list null (list 1 2 3))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">(1 (2 (3 ())))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">> (fold-left list null (list 1 2 3))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">(((() 1) 2) 3)</span><span style="color: #008000;"><br></span><span style="color: #000000;"><br></span><span style="color: #008000;">;</span><span style="color: #008000;"> (fold-right op i (a b c)) = (op a (op b (op c i)))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;"> (fold-left op i (a b c))  = (op (op (op i a) b) c)</span></div> <br>瑕?fold-right 鍜?fold-left 寰楀埌鐩稿悓鐨勭粨鏋滐紝鏄劇劧闇瑕?op 婊¤凍浜ゆ崲寰嬨?br><br><span style="font-weight: bold;">2.39</span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (reverse-</span><span style="color: #000000;">1</span><span style="color: #000000;"> seqs)<br>  (fold-right (lambda(x y) (append y (list x))) null seqs))<br>(define (reverse-</span><span style="color: #000000;">2</span><span style="color: #000000;"> seqs)<br>  (fold-left (lambda(x y) (cons y x)) null seqs))</span></div> <br><br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/55084.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-07-02 00:08 <a href="http://www.shnenglu.com/cuigang/archive/2008/07/02/55084.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.33~2.35錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/06/24/54420.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Mon, 23 Jun 2008 16:21:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/06/24/54420.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/54420.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/06/24/54420.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/54420.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/54420.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;"><span style="font-family: courier new; font-weight: bold;">2.33</span><br style="font-family: courier new;"><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (map+ p seque)<br>  (accumulate (lambda(x y) (cons (p x) y)) null seque))<br><br>(define (append seq1 seq2)<br>  (accumulate cons seq2 seq1))<br><br>(define (length seque)<br>  (accumulate (lambda(x y) (+ </span><span style="color: #000000;">1</span><span style="color: #000000;"> y)) </span><span style="color: #000000;">0</span><span style="color: #000000;"> seque))</span></div> <br style="font-family: courier new;"><span style="font-family: courier new; font-weight: bold;">2.34</span><br style="font-family: courier new;"><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (horner-eval x coeff-seque)<br>  (accumulate (lambda(this-coeff higher-coeff) <br>                (+ this-coeff (* x higher-coeff)))<br>              </span><span style="color: #000000;">0</span><span style="color: #000000;"> coeff-seque))</span></div> <br style="font-family: courier new;"><span style="font-family: courier new; font-weight: bold;">2.35</span><br style="font-family: courier new;"><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (count-leaves+ t)<br>  (accumulate + </span><span style="color: #000000;">0</span><span style="color: #000000;"> (map (lambda(x)<br>                         (if (pair? x) (count-leaves+ x) </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>                       t)))</span></div> <br style="font-family: courier new;"><br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/54420.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-06-24 00:21 <a href="http://www.shnenglu.com/cuigang/archive/2008/06/24/54420.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title> 鎴戠殑SICP涔犻絳旀錛?.27~2.32錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/06/17/53777.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Tue, 17 Jun 2008 15:48:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/06/17/53777.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/53777.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/06/17/53777.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/53777.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/53777.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;"><span style="font-family: courier new; font-weight: bold;">2.27</span><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (deep-reverse lst)<br>  (define (iter lst-o lst-d)<br>    (cond ((null? lst-o) <br>           lst-d)<br>          ((not (pair? (car lst-o))) <br>           (iter (cdr lst-o)<br>                 (cons (car lst-o) lst-d)))<br>          (else <br>           (iter (cdr lst-o) <br>                 (cons (deep-reverse (car lst-o))<br>                       lst-d)))))<br>  (iter lst null))</span></div> <br style="font-family: courier new;"><span style="font-family: courier new; font-weight: bold;">2.28</span><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (fringe x)<br>  (define (iter tree lst)<br>    (cond ((null? tree) lst)<br>          ((not (pair? tree)) (cons tree lst))<br>          (else (iter (car tree) (iter (cdr tree) lst)))))<br>  (iter x null))</span></div> <br style="font-family: courier new;"><span style="font-family: courier new; font-weight: bold;">2.30</span><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (square-tree- x)<br>  (cond ((null? x) null)<br>        ((not (pair? x)) (* x x))<br>        (else (cons (square-tree- (car x))<br>                    (square-tree- (cdr x))))))<br>(define (square-tree x)<br>  (map (lambda(subtree)<br>         (if (pair? subtree)<br>             (square-tree subtree)<br>             (* subtree subtree)))<br>       x))</span></div> <br style="font-family: courier new;"><span style="font-family: courier new; font-weight: bold;">2.31</span><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (tree-map proc tree)<br>  (map (lambda(subtree)<br>         (if (pair? subtree)<br>             (tree-map proc subtree)<br>             (proc subtree)))<br>       tree))<br>(define (square-tree+ tree)<br>  (tree-map (lambda(x) (* x x)) tree))</span></div> <br style="font-family: courier new;"><span style="font-family: courier new; font-weight: bold;">2.32</span><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (subsets s)<br>  (if (null? s)<br>      (list null)<br>      (let ((rest (subsets (cdr s))))<br>        (append rest (map (lambda(x) (cons (car s) x)) rest)))))</span></div> <span style="font-family: courier new;"><br>鍜屾崲闆墮挶闂鐨勬濊礬鏄竴鏍風殑錛屽浜庝竴涓泦鍚堢殑鎵鏈夊瓙闆嗙殑闆嗗悎錛屽彲浠ュ垎涓轟袱閮ㄥ垎錛屽惈鏈夌涓涓厓绱犲拰涓嶅惈絎竴涓厓绱犵殑闆嗗悎銆傝屼笖鍚涓涓厓绱犵殑鎵鏈夊瓙闆嗛櫎鍘葷涓涓厓绱狅紝鎭板ソ姝f槸鎵鏈変笉鍚涓涓厓绱犵殑瀛愰泦銆?/span><br style="font-family: courier new;"><span style="font-family: courier new;">涔熷彲浠ユ崲涓濊礬錛屽浜庨泦鍚圓錛岃瀹冨彲浠ヨ〃紺轟負 (a1)∪(a2,...,an) 錛岃?(a2,...,an) 鐨勬墍鏈夊瓙闆嗙殑闆嗗悎鏄?B=(B1,...Bm),閭d箞鍙互璇佹槑A鐨勬墍鏈夊瓙闆嗙殑闆嗗悎 C=B∪((A1)∪B1,(A1)∪B2,...,(A1)∪Bm);<br>璇佹槑錛氳 X 鏄?A 鐨勪竴涓瓙闆嗭紝閭d箞濡傛灉 a1∈X錛岄偅涔?X</span></span><span style="font-size: 10pt;"><span style="font-family: courier new;">∈</span></span><span style="font-size: 10pt;"><span style="font-family: courier new;">((A1)∪B1,(A1)∪B2,...,(A1)∪Bm)錛屽惁鍒?/span></span><span style="font-size: 10pt;"><span style="font-family: courier new;">X</span></span><span style="font-size: 10pt;"><span style="font-family: courier new;">∈B錛屾墍浠?br>    </span></span><span style="font-size: 10pt;"><span style="font-family: courier new;">X</span></span><span style="font-size: 10pt;"><span style="font-family: courier new;">∈C<br><br style="font-family: courier new;"></span></span><span style="font-size: 10pt;"><span style="font-family: courier new;"></span><br style="font-family: courier new;"><br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/53777.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-06-17 23:48 <a href="http://www.shnenglu.com/cuigang/archive/2008/06/17/53777.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title> 鎴戠殑SICP涔犻絳旀錛?.24~2.26錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/06/11/52948.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Wed, 11 Jun 2008 15:39:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/06/11/52948.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/52948.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/06/11/52948.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/52948.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/52948.html</trackback:ping><description><![CDATA[<span style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: courier new">2.24</span><br><br><img height=146 alt="" src="http://www.shnenglu.com/images/cppblog_com/cuigang/1.gif" width=391><br><br><span style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: courier new">2.25</span><br><br> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: courier new; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="FONT-SIZE: 10pt; COLOR: #000000">(car (cdaddr (list </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3</span><span style="COLOR: #000000"> (list </span><span style="COLOR: #000000">5</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">)))<br>(caar (list (list </span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">)))<br>(cadadr (cadadr(cadadr (list </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> (list </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"> (list </span><span style="COLOR: #000000">3</span><span style="COLOR: #000000"> (list </span><span style="COLOR: #000000">4</span><span style="COLOR: #000000"> (list </span><span style="COLOR: #000000">5</span><span style="COLOR: #000000"> (list </span><span style="COLOR: #000000">6</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">7</span><span style="COLOR: #000000">)))))))))</span></div> <span style="FONT-SIZE: 10pt"><br style="FONT-WEIGHT: bold; FONT-FAMILY: courier new"><span style="FONT-SIZE: 10pt; FONT-FAMILY: courier new"><span style="FONT-WEIGHT: bold">2.26</span><br><br style="FONT-FAMILY: courier new"> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: courier new; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">4</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">5</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">)<br>((</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">) </span><span style="COLOR: #000000">4</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">5</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">)<br>((</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">) (</span><span style="COLOR: #000000">4</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">5</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">6</span><span style="COLOR: #000000">))</span></div> <br><br><br><br></span></span><span style="FONT-FAMILY: courier new"></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/52948.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-06-11 23:39 <a href="http://www.shnenglu.com/cuigang/archive/2008/06/11/52948.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title> 鎴戠殑SICP涔犻絳旀錛?.17~2.23錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/06/11/52942.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Wed, 11 Jun 2008 14:56:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/06/11/52942.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/52942.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/06/11/52942.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/52942.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/52942.html</trackback:ping><description><![CDATA[<span style="font-family: courier new; font-size: 10pt; font-weight: bold;">2.17</span><br style="font-family: courier new;"><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: Comic Sans MS; color: #000000;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="font-family: courier new;">(define (last-pair lst)</span><br style="font-family: courier new;"><span style="font-family: courier new;">  (if (null? (cdr lst))</span><br style="font-family: courier new;"><span style="font-family: courier new;">      (cons (car lst) ())</span><br><span style="font-family: courier new;">      (last-pair (cdr lst))))</span></div> <span style="font-size: 10pt;"><br style="font-family: courier new;"><span style="font-weight: bold;">2.18</span></span><br style="font-family: courier new;"><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: Comic Sans MS; color: #000000;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="font-family: courier new;">(define (reverse lst)</span><br style="font-family: courier new;"><span style="font-family: courier new;">  (define (iter lst-o lst-d)</span><br><span style="font-family: courier new;">    (if (null? lst-o)</span><br style="font-family: courier new;"><span style="font-family: courier new;">        lst-d</span><br style="font-family: courier new;"><span style="font-family: courier new;">        (iter (cdr lst-o) (cons (car lst-o) lst-d))))</span><br><span style="font-family: courier new; font-size: 10pt;">  (iter lst null))</span></div> <br style="font-family: Comic Sans MS; font-weight: bold;"><span style="font-family: courier new; font-size: 10pt; font-weight: bold;">2.20</span><br style="font-family: Comic Sans MS;"><br style="font-family: Comic Sans MS;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: Comic Sans MS; color: #000000;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="font-family: courier new; font-size: 10pt;">(define (same-parity x . lst)</span><br style="font-family: courier new;"><span style="font-family: courier new;">  (define (filter lst ok?)</span><br style="font-family: courier new;"><span style="font-family: courier new;">    (if (null? lst)</span><br style="font-family: courier new;"><span style="font-family: courier new;">        ()</span><br style="font-family: courier new;"><span style="font-family: courier new;">        (if (ok? (car lst))</span><br style="font-family: courier new;"><span style="font-family: courier new;">            (cons (car lst) (filter (cdr lst) ok?))</span><br style="font-family: courier new;"><span style="font-family: courier new;">            (filter (cdr lst) ok?))))</span><br><span style="font-family: courier new; font-size: 10pt;">  (if (even? x)</span><br style="font-family: courier new;"><span style="font-family: courier new;">      (cons x (filter lst (lambda(x) (= 0 (remainder x 2)))))</span><br style="font-family: courier new;"><span style="font-family: courier new;">      (cons x (filter lst (lambda(x) (= 1 (remainder x 2)))))))</span></div> <br style="font-family: Comic Sans MS;"><span style="font-family: courier new; font-size: 10pt; font-weight: bold;"> 2.21</span><br style="font-family: Comic Sans MS;"> <br style="font-family: Comic Sans MS;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: Comic Sans MS; color: #000000;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="font-size: 10pt;"><span style="font-family: courier new;">(define (square-list- items)</span><br style="font-family: courier new;"><span style="font-family: courier new;">  (if (null? items)</span><br style="font-family: courier new;"><span style="font-family: courier new;">      ()</span><br style="font-family: courier new;"><span style="font-family: courier new;">      (cons (* (car items) (car items))</span><br style="font-family: courier new;"><span style="font-family: courier new;">            (square-list- (cdr items)))))</span><br><br style="font-family: courier new;"><span style="font-family: courier new;">(define (square-list items)</span><br style="font-family: courier new;"><span style="font-family: courier new;">  (map (lambda(x) (* x x)) items))</span></span></div> <span style="font-size: 10pt;"><br style="font-family: courier new;"><span style="font-family: courier new; font-weight: bold;"> 2.22</span><br style="font-family: courier new;"> <br style="font-family: courier new;"><span style="font-family: courier new;"> 絎竴縐嶆瘡嬈″彇鍑洪鍏冪礌騫蟲柟鍚庡墠鎻掑埌鏂拌〃錛岃薄reverse榪囩▼綾諱技錛屾墍浠ユ槸鍙嶇殑銆?/span><br style="font-family: courier new;"><span style="font-family: courier new;">絎簩縐嶅彧涓嶈繃鏄妸鏂拌〃鍓嶆彃鍒板厓绱犲墠錛屽緱鍒扮殑鐢氳嚦涓嶆槸涓涓猯ist錛岃屾槸</span><br style="font-family: courier new;"><span style="font-family: courier new;">  ((((() . 1) . 4) . 9) . 16) </span><br style="font-family: courier new;"> <br style="font-family: courier new;"><span style="font-family: courier new; font-weight: bold;"> 2.23</span><br style="font-family: courier new;"> </span><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: Comic Sans MS; color: #000000;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="font-family: courier new;">(define (for-each proc items)</span><br style="font-family: courier new;"><span style="font-family: courier new;">  (if (not (null? items))</span><br><span style="font-family: courier new;">      ((lambda() (proc (car items))</span><br style="font-family: courier new;"><span style="font-family: courier new;">       (for-each proc (cdr items))))))</span></div> <br> <img src ="http://www.shnenglu.com/cuigang/aggbug/52942.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-06-11 22:56 <a href="http://www.shnenglu.com/cuigang/archive/2008/06/11/52942.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title> 鎴戠殑SICP涔犻絳旀錛?.01~2.08錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/06/10/52803.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Tue, 10 Jun 2008 14:01:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/06/10/52803.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/52803.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/06/10/52803.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/52803.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/52803.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;"><br><span style="font-weight: bold;"> 2.01</span><br> <br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (make-rat x y)<br>  (let ((g (gcd x y)))<br>    (if (< y </span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>        (cons (/ (- x) g) (/ (- y) g))<br>        (cons (/ x g) (/ y g))))) </span></div> <br><span style="font-weight: bold;"> 2.02</span><br> <br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (make-point x y) (cons x y))<br>(define (x-point p) (car p))<br>(define (y-point p) (cdr p))<br><br>(define (make-segment p1 p2) (cons p1 p2))<br>(define (start-seg line) (car line))<br>(define (end-seg line) (cdr line))<br><br>(define (midpoint-segment line)<br>  (make-point (/ (+ (x-point (start-seg line)) (x-point (end-seg line))) </span><span style="color: #000000;">2.0</span><span style="color: #000000;">)<br>              (/ (+ (y-point (start-seg line)) (y-point (end-seg line))) </span><span style="color: #000000;">2.0</span><span style="color: #000000;">))) </span></div> <br><span style="font-weight: bold;"> 2.04</span><br> <br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><span style="color: #000000;"></span><span style="color: #008000;">;</span><span style="color: #008000;">;;;;;;;;;;;;;;;;;;;;;;;;</span><span style="color: #008000;"><br>;</span><span style="color: #008000;"> (cdr+ (cons+ x y) = ((cons+ x y) (lambda(p q) p)))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">            = (lambda(m)(m x y) (lambda(p q) p)))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">            = ((lambda(p q) p) x y)</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">            = x</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (cons+ x y)<br>  (lambda(m) (m x y)))<br>(define (car+ z)<br>  (z (lambda(p q) p)))<br>(define (cdr+ z)<br>  (z (lambda(p q) q))) </span></div> <br><span style="font-weight: bold;"> 2.05</span><br> <br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">  </span><span style="color: #000000;">2</span><span style="color: #000000;">^a * </span><span style="color: #000000;">3</span><span style="color: #000000;">^b </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;">^c * </span><span style="color: #000000;">3</span><span style="color: #000000;">^d (a!</span><span style="color: #000000;">=</span><span style="color: #000000;">c && b!</span><span style="color: #000000;">=</span><span style="color: #000000;">d)<br>  </span><span style="color: #000000;">2</span><span style="color: #000000;">^a/</span><span style="color: #000000;">2</span><span style="color: #000000;">^c </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">3</span><span style="color: #000000;">^d/</span><span style="color: #000000;">3</span><span style="color: #000000;">^b<br>  </span><span style="color: #000000;">2</span><span style="color: #000000;">^(a-c) </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">3</span><span style="color: #000000;">^(d-b)<br>  a</span><span style="color: #000000;">=</span><span style="color: #000000;">c && d</span><span style="color: #000000;">=</span><span style="color: #000000;">b</span></div> <br><span style="font-weight: bold;"> 2.06</span><br> <br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define one (lambda(f) (lambda(x) (f x))))<br>(define two (lambda(f) (lambda(x) (f (f x))))) </span></div> <br><span style="font-weight: bold;"> 2.07</span><br> <br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (upper-bound pair)<br>  (if (> (car pair) (cdr pair))<br>      (car pair)<br>      (cdr pair)))<br>(define (lower-bound pair)<br>  (if (> (car pair) (cdr pair))<br>      (cdr pair)<br>      (car pair))) </span></div> <br><span style="font-weight: bold;"> 2.08</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (sub-interval x y)<br>  (add-interval x (make-interval (- (upper-bound y))<br>                                 (- (lower-bound y))))) </span></div> <br> </span><img src ="http://www.shnenglu.com/cuigang/aggbug/52803.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-06-10 22:01 <a href="http://www.shnenglu.com/cuigang/archive/2008/06/10/52803.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title> 鎴戠殑SICP涔犻絳旀錛?.40~1.44錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/04/19/47632.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Sat, 19 Apr 2008 15:49:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/04/19/47632.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/47632.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/04/19/47632.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/47632.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/47632.html</trackback:ping><description><![CDATA[<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008000;">;</span><span style="color: #008000;">;;;;;;;;;;</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">1.43</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (double f)<br>  (lambda(x) (f (f x))))<br></span><span style="color: #008000;">;</span><span style="color: #008000;">;(((double (double double)) inc) 5) = 5+16 =21</span><span style="color: #008000;"><br></span><span style="color: #000000;"><br></span><span style="color: #008000;">;</span><span style="color: #008000;">;;;;;;;;;;;;</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">1.42</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (compose f g)<br>  (lambda(x) (f (g x))))<br><br></span><span style="color: #008000;">;</span><span style="color: #008000;">;;;;;;;;;;;;;;</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">1.43</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (repeated f n)<br>  (if(</span><span style="color: #000000;">=</span><span style="color: #000000;"> n </span><span style="color: #000000;">1</span><span style="color: #000000;">) f<br>     (compose f (repeated f (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">)))))<br><br></span><span style="color: #008000;">;</span><span style="color: #008000;">;;;;;;;;;;;;;;;</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">1.44</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (smooth f)<br>  (lambda(x) (/ (+ (f (- x dx))<br>                   (f x)<br>                   (f (+ x dx)))<br>                </span><span style="color: #000000;">3</span><span style="color: #000000;">)))<br><span style="color: #c4c3bd;">(define (smooth-n f)</span><br style="color: #c4c3bd;"><span style="color: #c4c3bd;">  (repeated f n))</span><br>(define (smooth-n f n)<br>  ((repeated smooth n) f)) <br><br></span></div> <br style="font-family: courier new;"> <img src ="http://www.shnenglu.com/cuigang/aggbug/47632.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-04-19 23:49 <a href="http://www.shnenglu.com/cuigang/archive/2008/04/19/47632.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.35~1.39錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/04/16/47169.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Tue, 15 Apr 2008 16:22:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/04/16/47169.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/47169.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/04/16/47169.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/47169.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/47169.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 8pt;"><span style="font-weight: bold; font-size: 10pt;">1.35<br><br></span></span><span style="font-size: 10pt;"><span style="font-family: courier new;"><span style="font-family: courier new;"></span>鑻?nbsp;φ=0 錛?nbsp;鍒?nbsp;φ^2=φ+1 涓嶆垚绔?nbsp;錛?nbsp;鏁?nbsp;φ≠0<br>φ^2 = φ+1 ==><br>φ = (φ+1)/φ = 1 + (1/φ) <br></span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="font-size: 10pt; font-family: courier new;">(fixed-point (lambda(x) (+ 1 (/ 1 x))) 1.0)</span></div> <br><span style="font-weight: bold; font-size: 10pt;">1.36</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; font-family: courier new; background-color: #eeeeee;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="font-size: 10pt; color: #000000;">(define tolerance </span><span style="color: #000000;">0.00001</span><span style="font-size: 10pt; color: #000000;">)<br><br>(define (fixed-point f first-guess)<br>  (define (close-enough? x y)<br>    (< (abs (- x y)) tolerance))<br>  (define (try guess)<br>    (let ((next (f guess)))<br>      (display next)<br>      (newline)<br>      (if (close-enough? guess next)<br>          next<br>          (try next))))<br>  (try first-guess))</span></div> <br>騫沖潎闃誨凹娉曞拰涓嶇敤騫沖潎闃誨凹鍒嗗埆濡備笅錛屽畠浠鏁板垎鍒負 9 鍜?34 銆?br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; font-family: courier new; background-color: #eeeeee;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="font-size: 10pt; color: #000000;">(fixed-point (lambda(x) (/ (+ x (/ (log </span><span style="color: #000000;">1000</span><span style="color: #000000;">) (log x))) </span><span style="color: #000000;">2</span><span style="color: #000000;">)) </span><span style="color: #000000;">2.0</span><span style="color: #000000;">)<br>(fixed-point (lambda(x) (/ (log </span><span style="color: #000000;">1000</span><span style="color: #000000;">) (log x))) </span><span style="color: #000000;">2.0</span><span style="color: #000000;">)</span></div> <br><span style="font-weight: bold;">1.37</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (cont-frac-r n d k)<br>  (define (redu i)<br>    (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> i k)<br>        (/ (n i) (d i))<br>        (/ (n i) (+ (d i) (redu n d (+ i </span><span style="color: #000000;">1</span><span style="color: #000000;">))))))<br>  (redu </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br><br>(define (cont-frac n d k)<br>  (define (iter i result)<br>    (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> i </span><span style="color: #000000;">0</span><span style="color: #000000;">) <br>        result<br>        (iter (- i </span><span style="color: #000000;">1</span><span style="color: #000000;">) (/ (n i) (+ (d i) result)))))<br>  (iter k </span><span style="color: #000000;">0</span><span style="color: #000000;">))<br><br>(define (get-phai k)<br>  (/ </span><span style="color: #000000;">1</span><span style="color: #000000;"> (cont-frac (lambda(i) </span><span style="color: #000000;">1.0</span><span style="color: #000000;">) (lambda(i) </span><span style="color: #000000;">1.0</span><span style="color: #000000;">) k)))<br><br>(define (get-k)<br>  (define (iter i)<br>    (if (< (abs (- (get-phai i) </span><span style="color: #000000;">1.6180</span><span style="color: #000000;">)) </span><span style="color: #000000;">0.00005</span><span style="color: #000000;">)<br>        i<br>        (iter (+ i </span><span style="color: #000000;">1</span><span style="color: #000000;">))))<br>  (iter </span><span style="color: #000000;">1</span><span style="color: #000000;">))</span></div> <br>k = 11 鏃訛紝綺懼害婊¤凍 4 浣?鍗佽繘鍒舵暟銆?br><br><span style="font-weight: bold;">1.38</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (euler-d i)<br>  (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> i </span><span style="color: #000000;">2</span><span style="color: #000000;">) </span><span style="color: #000000;">2.0</span><span style="color: #000000;">)<br>        ((and (> i </span><span style="color: #000000;">2</span><span style="color: #000000;">) (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;"> (remainder (- i </span><span style="color: #000000;">2</span><span style="color: #000000;">) </span><span style="color: #000000;">3</span><span style="color: #000000;">)))<br>         (* (/ (+ i </span><span style="color: #000000;">1</span><span style="color: #000000;">) </span><span style="color: #000000;">3.0</span><span style="color: #000000;">) </span><span style="color: #000000;">2.0</span><span style="color: #000000;">))<br>        (else </span><span style="color: #000000;">1.0</span><span style="color: #000000;">)))<br><br>(define (get-e k)<br>  (+ </span><span style="color: #000000;">2</span><span style="color: #000000;"> (cont-frac (lambda(i) </span><span style="color: #000000;">1.0</span><span style="color: #000000;">) euler-d k)))</span></div> <br><span style="font-weight: bold;">1.39</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (tan-cf x k)<br>  (define (tan-n i)<br>    (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;"> i)<br>        x<br>        (- (* x x))))<br>  (cont-frac tan-n (lambda(i) (- (* i </span><span style="color: #000000;">2.0</span><span style="color: #000000;">) </span><span style="color: #000000;">1.0</span><span style="color: #000000;">)) k))</span></div> <br></span></span><img src ="http://www.shnenglu.com/cuigang/aggbug/47169.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-04-16 00:22 <a href="http://www.shnenglu.com/cuigang/archive/2008/04/16/47169.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.34錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/04/06/46378.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Sun, 06 Apr 2008 08:46:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/04/06/46378.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/46378.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/04/06/46378.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/46378.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/46378.html</trackback:ping><description><![CDATA[<span style="font-size: 8pt;"><span style="font-family: courier new;">榪欎釜灞曞紑榪囩▼涓猴細<br><br style="font-family: courier new;"></span><span style="font-family: courier new;">(f f)</span><br style="font-family: courier new;"><span style="font-family: courier new;">(f 2)</span><br style="font-family: courier new;"><span style="font-family: courier new;">(2 2)<br><br style="font-family: courier new;"></span><span style="font-family: courier new;">瑙i噴鍣ㄥ皢鎶ラ敊錛?#8216;2’鏄竴涓湭瀹氫箟榪囩▼銆?/span><br style="font-family: courier new;"><br></span><img src ="http://www.shnenglu.com/cuigang/aggbug/46378.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-04-06 16:46 <a href="http://www.shnenglu.com/cuigang/archive/2008/04/06/46378.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.29~1.33錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/04/06/46375.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Sun, 06 Apr 2008 08:12:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/04/06/46375.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/46375.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/04/06/46375.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/46375.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/46375.html</trackback:ping><description><![CDATA[<span style="font-size: 8pt; font-family: courier new;"><span style="font-weight: bold;">1.29</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (simpson f a b n)<br>  (define (get-h) (/ (- b a) n))<br>  (define (get-y k) (f (+ a (* k (get-h)))))<br>  (define (simpson-term k)<br>    (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> k </span><span style="color: #000000;">0</span><span style="color: #000000;">) (get-y k))<br>          ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> k n) (get-y k))<br>          ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> (remainder k </span><span style="color: #000000;">2</span><span style="color: #000000;">) </span><span style="color: #000000;">0</span><span style="color: #000000;">) (* </span><span style="color: #000000;">2.0</span><span style="color: #000000;"> (get-y k)))<br>          (else (* </span><span style="color: #000000;">4.0</span><span style="color: #000000;"> (get-y k)))))<br>  (define (simpson-next k) (+ k </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>  (* (/ (get-h) </span><span style="color: #000000;">3.0</span><span style="color: #000000;">) (sum simpson-term </span><span style="color: #000000;">0</span><span style="color: #000000;"> simpson-next n))) </span></div> <br><span style="font-weight: bold;">1.30</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (sum term a next b)<br>  (define (iter a result)<br>    (if (> a b)<br>        result<br>        (iter (next a) (+ (term a) result))))<br>  (iter a </span><span style="color: #000000;">0</span><span style="color: #000000;">))</span></div> <br><span style="font-weight: bold;">1.31</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008000; font-size: 8pt;">;</span><span style="color: #008000;">;閫掑綊</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (product-re term a next b)<br>  (if (> a b)<br>      </span><span style="color: #000000;">1</span><span style="color: #000000;"><br>      (* (term a)<br>         (product-re term (next a) next b))))<br></span><span style="color: #008000;">;</span><span style="color: #008000;">;榪唬</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (product term a next b)<br>  (define (iter a result)<br>    (if (> a b)<br>        result<br>        (iter (next a) (* result (term a)))))<br>  (iter a </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br><br>(define (pi-product b)<br>  (define (pi-term k) (/ (* (- k </span><span style="color: #000000;">1</span><span style="color: #000000;">) (+ k </span><span style="color: #000000;">1</span><span style="color: #000000;">)) k k))<br>  (define (pi-next k) (+ k </span><span style="color: #000000;">2</span><span style="color: #000000;">))<br>  </span><span style="color: #008000;">;</span><span style="color: #008000;">;(* 4.0 (product-re pi-term 3.0 pi-next b))) ;;閫掑綊</span><span style="color: #008000;"><br></span><span style="color: #000000;">  (* </span><span style="color: #000000;">4.0</span><span style="color: #000000;"> (product pi-term </span><span style="color: #000000;">3.0</span><span style="color: #000000;"> pi-next b)))      </span><span style="color: #008000;">;</span><span style="color: #008000;">;榪唬</span><span style="color: #008000;"><br></span><span style="color: #000000;"><br></span></div> <br><span style="font-weight: bold;">1.32</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (sum term a next b)<br>  (accumulate + </span><span style="color: #000000;">0</span><span style="color: #000000;"> term a next b))<br><br>(define (product term a next b)<br>  (accumulate * </span><span style="color: #000000;">1</span><span style="color: #000000;"> term a next b))<br><br></span><span style="color: #008000;">;</span><span style="color: #008000;">;閫掑綊</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (accumulate-re combiner null-value term a next b)<br>  (if (> a b)<br>      null-value<br>      (combiner (term a)<br>                (accumulate-re combiner null-value term (next a) next b))))<br><br></span><span style="color: #008000;">;</span><span style="color: #008000;">;榪唬</span><span style="color: #008000;"><br></span><span style="color: #000000;">(define (accumulate combiner null-value term a next b)<br>  (define (iter a result)<br>    (if (> a b)<br>        result<br>        (iter (next a) (combiner (term a) result))))<br>  (iter a null-value))<br></span></div> <br><span style="font-weight: bold;">1.33</span><br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (filtered-accumulate combiner null-value term a next b filter?)<br>  (define (iter a result)<br>    (if (> a b)<br>        result<br>        (if (filter? (term a))<br>            (iter (next a) (combiner (term a) result))<br>            (iter (next a) result))))<br>  (iter a null-value))<br><br>(define (sum-prime a b)<br>  (define (sum-prime-term k) k)<br>  (define (sum-prime-next k) (+ k </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>  (filtered-accumulate + </span><span style="color: #000000;">0</span><span style="color: #000000;"> sum-prime-term a sum-prime-next b prime?))<br><br>(define (relatively-prime-product n)<br>  (define (relatively-prime? k) (</span><span style="color: #000000;">=</span><span style="color: #000000;"> (gcd k n) </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>  (define (term k) k)<br>  (define (next k) (+ k </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>  (filtered-accumulate * </span><span style="color: #000000;">1</span><span style="color: #000000;"> term </span><span style="color: #000000;">2</span><span style="color: #000000;"> next (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">) relatively-prime?))</span></div> <br><br><br></span><img src ="http://www.shnenglu.com/cuigang/aggbug/46375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-04-06 16:12 <a href="http://www.shnenglu.com/cuigang/archive/2008/04/06/46375.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.24~1.28錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/31/45781.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Sun, 30 Mar 2008 16:21:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/31/45781.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/45781.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/31/45781.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/45781.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/45781.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;"><span style="font-size: 8pt;"><span style="font-family: courier new; font-weight: bold;">1.24</span><br style="font-family: courier new;"><span style="font-family: courier new; font-size: 10pt;">瀵逛簬Fermat媯鏌ワ紝鍥犱負鍏鋒湁log n 鐨勫闀塊樁錛屾墍浠ュ浜?n^2 鍜?n 鐨勬鏌ョ殑鏃墮棿姣?鐞嗚涓婂簲璇ユ槸 2錛?錛?瀹為檯涓婏紝緇忚繃嫻嬭瘯涔熸瘮杈冩帴榪戯紝褰搉姣旇緝澶ф椂銆?br>鑻ヤ笌棰勮涓嶇錛屽彲鑳藉洜涓?n 姣旇緝灝忥紝鎴栬呭瓧闀垮彂鐢熷彉鍖栵紝姣斿 n > 2^32 錛堝弬瑙佷笅棰橈級<br><br><span style="font-weight: bold;">1.25</span><br>浠呬粠鐞嗚鍒嗘瀽錛孉lyssa 鐨勬敼鍔ㄤ笉浼氬紩璧峰闀塊樁鐨勫彉鍖栵紝浣嗗疄闄呬笂褰?Fermat 媯鏌ョ殑 n 紼嶅井澶т竴鐐癸紝閫熷害灝變細寰堟參銆備富瑕佸師鍥?灝辨槸 base^exp 鏄竴涓潪甯稿ぇ鐨勬暟錛屽彲鑳借繙榪滆秴榪?涓涓?2浣嶆満瀛楃殑琛ㄧず鑼冨洿 2^32 錛屽湪 scheme 閲屽彲鑳界敤鑻ュ共涓?32-bit 闈犺蔣浠跺疄鐜拌繍綆楋紝榪欏皢瀵艱嚧璁$畻鎬ラ熷闀褲傛棤璁烘槸浼犻掋佽繍綆楄繕鏄眰妯°?br>瀹為檯涓?1.22銆?.23銆?.24 鐨勫嚑涓鐩彲鑳介兘浼氶亣鍒板瓧闀垮彉鍖栧紩璧風殑璁$畻閫熷害紿佸彉銆?br><br><span style="font-weight: bold;">1.26</span><br>Fermat 媯鏌ユ鏄洜涓?榪炵畫姹傚鉤鏂圭殑姹傚箓鏂規硶錛屼嬌寰楃殑澧為暱闃跺彉涓?log n錛?鑰岃繖鍧囨潵婧愪簬 b^(2n) = (b^n)^2錛?/span></span><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;">Louis 鐨勬柟娉曡姹傚箓鍙堝彉鎴愪簡榪炰箻錛宐^(2n) = b^n*b^n = (b*b*...*b)*(b*b*...*b)錛屾眰騫傜殑澧為暱闃跺彉鎴愪簡 O(n)錛孎ermat 媯鏌ョ殑澧為暱闃惰嚜鐒朵篃鍙樻垚浜?O(n)銆?br><br><span style="font-weight: bold;">1.27</span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000; font-size: 10pt;">(define (fermat-test n)<br>  (fermat-iter (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">) n))<br><br>(define (fermat-iter a n)<br>  (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> a </span><span style="color: #000000;">0</span><span style="color: #000000;">) #t)<br>        ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> (expmod a n n) a) (fermat-iter (- a </span><span style="color: #000000;">1</span><span style="color: #000000;">) n))<br>        (else #f)))</span></div> <br><span style="font-weight: bold;">1.28</span><br>棣栧厛鏉ョ湅錛孎ermat 灝忓畾鐞嗙殑涓涓彉褰細<br><br>p 鏄礌鏁? 1<a<p, 鏈?a^p % p = a<br>==> a^p = kp + a ==> a^p - a = kp ==> a(a^(p-1)-1) = kp ==> a^(p-1) -1 = k'p<br>==> a^(p-1) % p = 1<br><br>榪欎釜鍙樺艦灝辨槸棰樼洰涓彁鍒扮殑錛岃繖涓艦寮忓拰璐歸┈灝忓畾鐞嗘槸絳変環鐨勶紙浣嗘槸濂囨殑鏄紝鎴戞病鏈夊彂鐜板凡鐭ョ殑鍑犱釜Carmichael鏁拌兘澶熻翰榪囪繖涓彉褰㈢殑媯鏌ワ紝鏈夊緟鐮旂┒<span style="color: #eec859; font-weight: bold;">鈶?/span>錛?br><br>鍐嶆潵鐪嬶紝miller-rabin 绱犳ф祴璇曠殑鍘熺悊錛?br><br>p 鏄礌鏁幫紝 1<a<p, 涓?a^2 % p = 1<br>==> (a^2-1) % p = 0 ==> (a+1)(a-1) % p =0<br>閭d箞 a+1 % p = 0 鎴栬?a-1 % p =0,<br>鍙?a<p 涓?p 鏄礌鏁幫紝鎵浠?br>a = 1 鎴栬?a = p-1 錛堣繖涓や釜鍙仛 1妯鐨勫鉤鍑″鉤鏂規牴錛?br></span></span></span><span style="font-size: 10pt;"><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;"></span></span></span><br><span style="font-size: 10pt;"><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;"></span></span><span style="font-size: 8pt;">浠g爜濡備笅錛?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000; font-size: 10pt; font-family: courier new;">(define (check-nontrivial-sqrt-of-one a n)<br>  (define (check-</span><span style="color: #000000; font-family: courier new;">1? t)<br>    (if (and (> a 1</span><span style="color: #000000;"><span style="font-family: courier new;">)</span><br>             (< a (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>             (</span><span style="color: #000000;">=</span><span style="color: #000000;"> t </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>        </span><span style="color: #000000;">0</span><span style="color: #000000;"> t))<br>  (check-</span><span style="color: #000000;">1</span><span style="color: #000000;">? (remainder (square a) n)))<br><br>(define (expmod base exp m)<br>  (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> exp </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>        ((even? exp)<br>         </span><span style="color: #008000;">;</span><span style="color: #008000;">(remainder (square (expmod base (/ exp 2) m)) m))</span><span style="color: #008000;"><br></span><span style="color: #000000;">         (check-nontrivial-sqrt-of-one (expmod base (/ exp </span><span style="color: #000000;">2</span><span style="color: #000000;">) m) m))<br>        (else<br>         (remainder (* base (expmod base (- exp </span><span style="color: #000000;">1</span><span style="color: #000000;">) m)) m))))<br><br>(define (miller-rabin-test n)<br>  (define (iter x n)<br>    (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> x </span><span style="color: #000000;">0</span><span style="color: #000000;">) #t)<br>          ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> (expmod x (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">) n) </span><span style="color: #000000;">1</span><span style="color: #000000;">) (iter (- x </span><span style="color: #000000;">1</span><span style="color: #000000;">) n))<br>          (else #f)))<br>  (iter (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">) n))</span></div> <br><span style="color: #eec859; font-weight: bold;">鈶?瀵逛簬 </span></span></span><span style="font-size: 10pt; color: #eec859; font-weight: bold;"><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;">Carmichael 鏁?n 錛屽疄闄呬笂涓嶈兘瀹屽叏閫氳繃 </span></span><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;"></span></span></span><span style="font-size: 10pt; color: #eec859;"><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;"><span style="font-weight: bold;">a^(n-1)%n = 1 鐨勬鏌?/span></span></span></span><span style="font-size: 10pt; color: #eec859; font-weight: bold;"><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;">錛岄櫎闈?a 涓?n 浜掔礌錛屽綋 a 涓?n 鐨勭礌鍥犲瓙鏃訛紝涓嶈兘閫氳繃錛屾瘮濡?</span></span><span style="font-size: 8pt;"></span><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;">Carmichael 絎竴涓?561 = 3*11*17錛?鑰?3^560%561 = 375 ≠ 1 銆傚彲浠ョ▼搴忛獙璇佽繖涓?鎵浠ユ垜璁や負錛?/span></span><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;">a^(n-1)%n = 1 鐨勬鏌ユ瘮 a^n%n = a 鐨勬鏌ユ洿涓ユ牸錛屾槸涓嶆槸涓嶅瓨鍦ㄥ悎鏁伴氳繃瀹屽叏鐨?</span></span></span><span style="font-size: 10pt;"><span style="font-size: 8pt;"><span style="font-family: courier new; font-size: 10pt;"><span style="color: #3925c6; font-weight: bold;"><span style="color: #eec859;">a^(n-1)%n = 1 鐨勬鏌ュ憿錛熸垜涓嶆暍璇淬備絾鎶婅繖涓粨璁烘殏鏃惰鍦ㄨ繖閲岋紝甯屾湜鑳藉緱鍒板府鍔╂垨鑰呭弽椹熾?008-04-02 23:56</span><br><br></span><br></span></span></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/45781.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-31 00:21 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/31/45781.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.21~1.23錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/28/45648.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Fri, 28 Mar 2008 15:44:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/28/45648.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/45648.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/28/45648.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/45648.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/45648.html</trackback:ping><description><![CDATA[<span style="font-size: 8pt; font-family: courier new;"><span style="font-size: 8pt;"><span style="font-weight: bold; font-size: 8pt;">1.21<br><br></span><span style="font-size: 8pt; font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">> (smallest-divisor </span><span style="color: #000000;">199</span><span style="color: #000000;">)<br></span><span style="color: #000000;">199</span><span style="color: #000000;"><br>> (smallest-divisor </span><span style="color: #000000;">1999</span><span style="color: #000000;">)<br></span><span style="color: #000000;">1999</span><span style="color: #000000;"><br>> (smallest-divisor </span><span style="color: #000000;">19999</span><span style="color: #000000;">)<br></span><span style="color: #000000;">7</span><span style="color: #000000;"><br>></span></div> </span><span style="font-weight: bold; font-size: 8pt;"><br></span><span style="font-weight: bold;">1.22</span><br>鍦?DrScheme 涓病鏈夊搴旂殑 runtime 榪囩▼錛屾垜浠敤鍐呭緩鐨?current-milliseconds 鏉ヤ唬鏇匡紝榪欎釜榪囩▼榪斿洖鐨勬槸緋葷粺鐨?ms 鏁般?br>鍚屾椂錛屽湪 Windows 涓嬫棤娉曠簿紜〃紺?16ms 浠ヤ笅鐨勭簿搴︼紙鍙兘鏃墮棿鐗囩殑澶у皬鏄?16ms 錛夛紝鎵浠ヨ繖閲岀敤姣旇緝澶х殑鏁版潵嫻嬭瘯銆?br>浠g爜濡備笅<br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (even? x) (</span><span style="color: #000000;">=</span><span style="color: #000000;"> (remainder x </span><span style="color: #000000;">2</span><span style="color: #000000;">) </span><span style="color: #000000;">0</span><span style="color: #000000;">))<br><br>(define (runtime) (current-milliseconds))<br><br>(define (start-prime-test n start-time)<br>  (and (prime? n)<br>       (report-prime (- (runtime) start-time))))<br><br>(define (report-prime elapsed-time)<br>  (display </span><span style="color: #000000;">"</span><span style="color: #000000;"> *** </span><span style="color: #000000;">"</span><span style="color: #000000;">)<br>  (display elapsed-time))<br><br>(define (search-iter cur-num index start-time)<br>  (newline)<br>  (display cur-num)<br>  (if (not (</span><span style="color: #000000;">=</span><span style="color: #000000;"> index </span><span style="color: #000000;">0</span><span style="color: #000000;">))<br>      (if (start-prime-test cur-num start-time)<br>          (search-iter (+ cur-num </span><span style="color: #000000;">2</span><span style="color: #000000;">) (- index </span><span style="color: #000000;">1</span><span style="color: #000000;">) start-time)<br>          (search-iter (+ cur-num </span><span style="color: #000000;">2</span><span style="color: #000000;">) index start-time))))<br><br>(define (search-for-primes start-number)<br>  (if (even? start-number)<br>      (search-iter (+ start-number </span><span style="color: #000000;">1</span><span style="color: #000000;">) </span><span style="color: #000000;">3</span><span style="color: #000000;"> (runtime))<br>      (search-iter start-number </span><span style="color: #000000;">3</span><span style="color: #000000;"> (runtime))))<br></span></div> <br>榪欓噷鐢ㄥ埌浜?prime? 璋撹瘝錛屼唬鐮佷笉鍐嶅榪般?br>                             <br>|------+--------+--------+-------|<br>|10^9  | 10^10  | 10^11  | 10^12 | => start-number<br>|------+--------+--------+-------|<br>|31    | 250    | 609    | 1953  | (ms)<br>|47    | 406    | 1203   | 3844  |<br>|78    | 625    | 1859   | 5719  |<br>|------+--------+--------+-------|<br><br></span>浠庝笂琛ㄥ彲浠ョ湅鍑猴紝闄や簡鍓嶄袱鍒椾箣闂達紝鍚庡垪鐨勬暟瀛楅兘鏄墠鍒楁暟瀛楃殑 3 鍊嶅乏鍙籌紝榪戜技浜?√10 鈮?3.16銆傚疄闄呬笂錛岄殢鐫 n 鐨勪笉鏂澶э紝榪欎釜鏁頒細閫愭笎閫艱繎 √10銆?br><br><span style="font-weight: bold;">1.23<br><br></span> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (next n)<br>  (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> n </span><span style="color: #000000;">2</span><span style="color: #000000;">) </span><span style="color: #000000;">3</span><span style="color: #000000;"> (+ n </span><span style="color: #000000;">2</span><span style="color: #000000;">)))<br><br>(define (find-divisor n test-divisor)<br>  (cond ((> (square test-divisor) n) n)<br>        ((divides? test-divisor n) test-divisor)<br>        (else (find-divisor n (next test-divisor)))))</span></div> <br>璁$畻緇撴灉濡備笅錛?br>|--------+--------+-------|<br>| 10^10  | 10^11  | 10^12 | => start-number<br>|--------+--------+-------|<br>| 141    | 297    | 1078  | (ms)<br>| 219    | 609    | 2093  |<br>| 313    | 984    | 3140  |<br>|--------+--------+-------| <br><br>鍙互鐪嬪嚭榪欎釜姣斿煎ぇ綰﹀湪 1.8(1/0.55) 宸﹀彸錛屽彲鑳藉師鍥犳槸鍏跺畠鐨勮綆楅渶瑕佹椂闂達紝浣嗗綋 n 涓嶆柇澧炲ぇ錛屽叾瀹冭綆楁槸甯告暟闃訛紝榪欎釜姣斿間細涓嶆柇鎺ヨ繎2銆?br><br><br></span><img src ="http://www.shnenglu.com/cuigang/aggbug/45648.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-28 23:44 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/28/45648.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.20錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/27/45554.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Thu, 27 Mar 2008 13:59:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/27/45554.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/45554.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/27/45554.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/45554.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/45554.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;"><span style="font-weight: bold;">1.20</span><br>涓嬮潰鐢?% 琛ㄧず榪囩▼ remainder錛岄偅涔堟鍒欏簭鐨勮繃紼嬪涓嬶細<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;"> (gcd </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)<br> (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">206</span><span style="color: #000000;"> (gcd </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)))<br> (gcd </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))<br> (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #008000;">;</span><span style="color: #008000;"><##  1> [6]</span><span style="color: #008000;"><br></span><span style="color: #000000;">     </span><span style="color: #000000;">40</span><span style="color: #000000;"> <br>     (gcd (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))<br> (gcd (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)))<br> (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)) </span><span style="color: #000000;">0</span><span style="color: #000000;">)   </span><span style="color: #008000;">;</span><span style="color: #008000;"><##  2> [4]</span><span style="color: #008000;"><br></span><span style="color: #000000;">     (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)<br>     (gcd (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)) (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)))))<br> (gcd (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)) (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))))<br> (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))) </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #008000;">;</span><span style="color: #008000;"><## 4>[2]</span><span style="color: #008000;"><br></span><span style="color: #000000;">     (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))<br>     (gcd (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)))<br>          (% (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)) (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))))))<br> (gcd (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)))<br>      (% (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)) (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))))))<br> (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> (% (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)) (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))))) </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #008000;">;</span><span style="color: #008000;"><## 7>[0]</span><span style="color: #008000;"><br></span><span style="color: #000000;">     (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)))<br>     (gcd ...)<br> (% (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">) (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)))  </span><span style="color: #008000;">;</span><span style="color: #008000;"><## 4>[2]</span><span style="color: #008000;"><br></span></div> <br>鍙互鐪嬪嚭闇瑕佽皟鐢?remainder 鍏?1+2+4+7+4 = 18 嬈°?br><br>搴旂敤搴忚綆楄繃紼嬪涓嬶細<br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(gcd </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">)<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">206</span><span style="color: #000000;"> (gcd </span><span style="color: #000000;">40</span><span style="color: #000000;"> (% </span><span style="color: #000000;">206</span><span style="color: #000000;"> </span><span style="color: #000000;">40</span><span style="color: #000000;">))) </span><span style="color: #008000;">;</span><span style="color: #008000;"><##></span><span style="color: #008000;"><br></span><span style="color: #000000;">(gcd </span><span style="color: #000000;">40</span><span style="color: #000000;"> </span><span style="color: #000000;">6</span><span style="color: #000000;">)<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">6</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">40</span><span style="color: #000000;"> (gcd </span><span style="color: #000000;">6</span><span style="color: #000000;"> (% </span><span style="color: #000000;">40</span><span style="color: #000000;"> </span><span style="color: #000000;">6</span><span style="color: #000000;">)))      </span><span style="color: #008000;">;</span><span style="color: #008000;"><##></span><span style="color: #008000;"><br></span><span style="color: #000000;">(gcd </span><span style="color: #000000;">6</span><span style="color: #000000;"> </span><span style="color: #000000;">4</span><span style="color: #000000;">)<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">4</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">6</span><span style="color: #000000;"> (gcd </span><span style="color: #000000;">4</span><span style="color: #000000;"> (% </span><span style="color: #000000;">6</span><span style="color: #000000;"> </span><span style="color: #000000;">4</span><span style="color: #000000;">)))        </span><span style="color: #008000;">;</span><span style="color: #008000;"><##></span><span style="color: #008000;"><br></span><span style="color: #000000;">(gcd </span><span style="color: #000000;">4</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;">)<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">4</span><span style="color: #000000;"> (gcd </span><span style="color: #000000;">2</span><span style="color: #000000;"> (% </span><span style="color: #000000;">4</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;">)))        </span><span style="color: #008000;">;</span><span style="color: #008000;"><##></span><span style="color: #008000;"><br></span><span style="color: #000000;">(gcd </span><span style="color: #000000;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">2</span><span style="color: #000000;"> (gcd </span><span style="color: #000000;">0</span><span style="color: #000000;"> (% </span><span style="color: #000000;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">)))<br></span><span style="color: #000000;">2</span></div> <br>鍙互鐪嬪嚭鍏遍渶 4 嬈°?br><br><br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/45554.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-27 21:59 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/27/45554.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.16~1.19錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/27/45482.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Wed, 26 Mar 2008 16:53:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/27/45482.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/45482.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/27/45482.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/45482.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/45482.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;"><span style="font-weight: bold;">1.16</span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (fast-expt x n)<br>  (fast-expt-iter x n </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br><br>(define (fast-expt-iter x n a)<br>  (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> n </span><span style="color: #000000;">0</span><span style="color: #000000;">) a)<br>        ((even? n) (fast-expt-iter (square x) <br>                                   (/ n </span><span style="color: #000000;">2</span><span style="color: #000000;">)<br>                                   a))<br>        (else (fast-expt-iter x <br>                              (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">)<br>                              (* a x)))))</span></div> <br style="font-weight: bold;"><span style="font-weight: bold;">1.17</span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (multi x y)<br>  (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> y </span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>      </span><span style="color: #000000;">0</span><span style="color: #000000;"><br>      (+ x (multi x (- y </span><span style="color: #000000;">1</span><span style="color: #000000;">)))))<br><br>(define (fast-multi x y)<br>  (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> y </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>        ((even? y) (double (fast-multi x<br>                               (half y))))<br>        (else (+ x (fast-multi x (- y </span><span style="color: #000000;">1</span><span style="color: #000000;">))))))<br><br>(define (double x) (+ x x))<br>(define (half y) (/ y </span><span style="color: #000000;">2</span><span style="color: #000000;">))</span></div> <br><span style="font-weight: bold;">1.18</span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (double x) (+ x x))<br>(define (half y) (/ y </span><span style="color: #000000;">2</span><span style="color: #000000;">))<br><br>(define (fast-multi x y)<br>  (fast-multi-iter x y </span><span style="color: #000000;">0</span><span style="color: #000000;">))<br><br>(define (fast-multi-iter x y p)<br>  (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> y </span><span style="color: #000000;">0</span><span style="color: #000000;">) p)<br>        ((even? y) (fast-multi-iter (double x)<br>                                    (half y)<br>                                    p))<br>        (else (fast-multi-iter x (- y </span><span style="color: #000000;">1</span><span style="color: #000000;">) (+ p x)))))</span></div> <br><span style="font-weight: bold;">1.19</span><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008000;">;</span><span style="color: #008000;">T(pq):(a,b)=>(bq+aq+ap, bp+aq)</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">T(pq):(bq+aq+ap, bp+aq)=>((bp+aq)q + (bq+aq+ap)q + (bq+aq+ap)p,</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">                          (bp+aq)p + (bq+aq+ap)q)</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">      => (2bpq+2aqq+bqq+2apq+app, bpp+2apq+bqq+aqq)</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">      => (b(2pq+qq)+a(2pq+qq)+a(qq+pp), b(qq+pp)+a(2pq+qq))</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">q' = 2pq+qq</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">p' = qq+pp</span><span style="color: #008000;"><br>;<br></span><span style="color: #000000;"></span><span style="color: #000000;">(define (fib n)<br>  (fib-iter </span><span style="color: #000000;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;"> n))<br><br>(define (fib-iter a b p q count)<br>  (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> count </span><span style="color: #000000;">0</span><span style="color: #000000;">) b)<br>        ((even? count) <br>         (fib-iter a<br>                   b<br>                   (+ (* p p) (* q q))<br>                   (+ (* </span><span style="color: #000000;">2</span><span style="color: #000000;"> p q ) (* q q))<br>                   (/ count </span><span style="color: #000000;">2</span><span style="color: #000000;">)))<br>        (else (fib-iter (+ (* b q) (* a q) (* a p))<br>                        (+ (* b p) (* a q))<br>                        p<br>                        q<br>                        (- count </span><span style="color: #000000;">1</span><span style="color: #000000;">)))))<br></span></div> <br><br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/45482.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-27 00:53 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/27/45482.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.14~1.15錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/26/45470.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Wed, 26 Mar 2008 14:56:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/26/45470.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/45470.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/26/45470.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/45470.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/45470.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-weight: bold;">1.14</span><br>璁$畻榪囩▼鐨勬爲濡備笅錛?br><img alt="" src="http://www.shnenglu.com/images/cppblog_com/cuigang/111.jpg" height="413" width="488"><br></span><br>寰堝鏄撶湅鍑猴紝璁$畻榪囩▼鐨勭┖闂撮渶姹傦紝涔熷氨鏄爲鐨勬繁搴︼紝鍙栧喅浜庢渶宸﹁竟鐨勫瓙鏍戯紝鍗?n 1)錛屽畠鐨勬繁搴︽槸n+6錛孫(n).<br><br>鐒跺悗瀵逛簬璁$畻姝ユ暟錛屼篃灝辨槸鏍戠殑鑺傜偣鏁幫紝鎴戜滑鐭ラ亾瀵逛簬涓涓簩鍙夋爲錛屾爲鐨勮妭鐐規暟 = 宸﹀瓙鏍戣妭鐐規暟 + 鍙沖瓙鏍戣妭鐐規暟 + 1.<br>鍏堟潵鐪?(n 1) 瀛愭爲錛岃瀹冪殑鑺傜偣鏁版槸f(n), 鑰屼笖鎬繪湁錛岄潪鍙惰妭鐐瑰乏瀛愭爲鑺傜偣鏁頒負1<br>褰?n=1錛宖(1) = 3<br>   n>1, f(n) = 1 + f(n-1) + 1 = f(n-1) + 2 = f(n-2) + 2*2 <br>             = f(n-(n-1)) + 2*(n-1) = 2n + 1<br>             = O(n)<br><br>鍐嶆潵鐪?(n 2) 瀛愭爲錛岃瀹冪殑鑺傜偣鏁?g(n), 璁?鈹?n/5 鈹?= A <br>g(n) = f(n) + g(n-5) + 1 = f(n) + f(n-5) + g(n-5*2) + 2<br>     = f(n) + ... + f(n-5*(A-1)) + g(n-5*A) + 2A<br>     = O(n^2)<br><br>渚濇綾繪帹錛屽彲浠ュ緱鍑虹粨璁?(n 5) 鐨勮綆楁鏁板闀跨殑闃?涓?O(n^5)<br><br><span style="font-weight: bold;">1.15</span><br>a) 12.15 榪為櫎 5嬈?3 灝忎簬 0.1 錛屾墍浠ユ槸 5嬈?br>b) 鍙互鐪嬪嚭姣忚皟鐢ㄤ竴嬈?p 榪囩▼錛岄渶瑕侀掑綊1嬈?sine 錛岀┖闂村姞1錛岃綆楁鏁板姞2錛屽叧閿槸p鐨勬鏁幫細<br>   瀵逛簬a錛岃皟鐢ㄦ鏁皌錛岄偅涔?a*3^(-t) < 0.1 , 鍗?10a < 3^t ==> lg(10a)/lg3 < t,<br>   鎵浠ュ闀塊樁 絀洪棿鍜屾椂闂?閮戒負 O(log a)<br><br><br><br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/45470.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-26 22:56 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/26/45470.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎺ㄨ崘 SICPhttp://www.shnenglu.com/cuigang/archive/2008/03/18/44801.htmlcuigangcuigangTue, 18 Mar 2008 13:57:00 GMThttp://www.shnenglu.com/cuigang/archive/2008/03/18/44801.htmlhttp://www.shnenglu.com/cuigang/comments/44801.htmlhttp://www.shnenglu.com/cuigang/archive/2008/03/18/44801.html#Feedback13http://www.shnenglu.com/cuigang/comments/commentRss/44801.htmlhttp://www.shnenglu.com/cuigang/services/trackbacks/44801.html鎴戜負浠涔堟帹鑽?SICP錛?/span>

鍚戝ぇ瀹舵帹鑽?SICP錛屼笉鐭ラ亾鏈夊灝戜漢鐪嬩簡錛屼篃涓嶇煡閬撴湁澶氬皯浜烘槑鐧戒簡錛屾洿涓嶇煡閬撴湁澶氬皯浜烘儕鍙逛簡銆傛垨鑰呬綘鏍規湰涓嶅睉涓欏撅紝鎴栬呬綘鐪嬭 Lisp 閭e眰灞傛嫭鍙峰績鐢熺晱鎯э紝鍙堟垨鑰呬綘浜嗕簡涓鐬ワ紝瑙夊緱娌′粈涔堢簿褰╀箣澶勩傞偅鎴戠湡鐨勫緢澶辨湜銆?/span>
 
鎴戜負浠涔堣鎺ㄨ崘SICP錛岃屼笖涓轟粈涔堝姝ゆ墽鐫錛熻繖鏈笉綆楀帤鐨勪功甯︾粰鎴戠殑瑙傚康錛屾槸浠庢湭鏈夎繃鐨勶紝鏄叧涔庝簬杞歡鏈川鐨勩傛浘鍑犱綍鏃訛紝鎴戣寰楁垜鐪嬪埌浜嗚綆楁満緙栫▼涔︿腑娌℃湁鐨勫摬瀛﹁錛屼絾榪欎竴嬈℃垜鐨勬ⅵ鐮寸伃浜嗭紝閭d簺宸茬粡琚啓榪涗功閲屽樊涓嶅蹇?30 騫翠簡銆?/span>
 
瀵逛簬 SICP錛屾垜鐪熸綆楃湅瀹岀殑錛屾亹鎬曞彧鏈夌涓绔犮傛垜鐜板湪灝辨潵璋堣皥鎴戠殑蹇冨緱錛屼互鍐嶆鍚戜綘灞曠幇榪欐湰涔︾殑欖斿姏銆?/span>
 
絎竴绔犱綔涓哄熀紜錛屼綔鑰呭茍娌℃湁璞″悗緇珷鑺傚啓澶鐨勮蔣浠舵濇兂錛屼富瑕佽繕鏄粙緇?Scheme 璇█錛屾墍浠ヨ崏鑽夌湅鍘伙紝娌′粈涔堢簿杈熶箣澶勩備笉榪囧湪絎竴绔犱腑錛屼綔鑰呯敤浜嗗ぇ閲忕殑綃囧箙鏉ユ帰璁ㄦ暟瀛﹂棶棰橈紝鍥犱負浠栨兂鍚戜綘鎻ず紼嬪簭璁捐涓殑鏍稿績鍝插錛氭娊璞°傝屾暟瀛︽棤鐤戞槸鏈濂界殑渚嬪瓙銆?/span>
 
浜嗚В鏁板鍙茬殑浜猴紝搴旇鐭ラ亾鏁翠釜鏁板鍙詫紝灝辨槸涓涓笉鏂娊璞$殑鍘嗗彶銆傚彜甯岃厞浜哄皢瀛楁瘝寮曞叆璁$畻錛屼嬌鏁板涓嶅啀鍙槸綆楁湳錛岃屼笖鍏鋒湁琛ㄨ揪鎶借薄瑙勫垯鐨勮兘鍔涖傝繎浠f暟瀛﹀鍑芥暟鍜屽井縐垎鐨勬帰姹備腑錛岀敤 f(x) 鏇夸唬浜嗗欏瑰紡琛ㄨ揪寮忥紝鍑芥暟鏇翠竴鑸簡錛岀劧鍚?n 緇寸┖闂淬佸鍒嗘瀽銆佹槧灝勩佹硾鍑斤紝鎶借薄浠f暟銆佺兢璁猴紝絳夌瓑絳夌瓑錛岀洿鍒伴泦鍚堣錛屾懅姣佷簡鏁板鐨勫熀鐭籌紝浣挎暟瀛︾晫鍐嶆闄峰叆娌夋濄?/span>
 
鏋勯犵▼搴忕殑鏂規硶涔熸槸鎶借薄銆備粠鏈綆鍗曠殑鍏冪礌寮濮嬶紝鍩烘湰鍏冪礌(鑷紨綆楄〃杈懼紡錛屽寘鎷暟瀛楋紝瀛楃涓插拰甯冨皵鍊鹼級錛岀劧鍚庡畾涔夊熀鏈繃紼嬶紙鍩烘湰榪愮畻絎︼紝鍥涘垯榪愮畻鍜屽竷灝旇繍綆楋級錛岃繘涓姝ワ紝鑷畾涔夋爣璇嗙錛堝鍚屼唬鏁幫級錛屽啀鑷畾涔夎繃紼嬶紙鍑芥暟錛夛紝鍐嶅皢榪囩▼浣滀負鍊煎弬涓庤繍綆楋紙楂橀樁榪囩▼錛夈備竴姝ユ鐨勬娊璞★紝褰㈡垚浜嗘暣涓▼搴忕殑緇撴瀯銆傝屾垜浠紪紼嬶紝鏃犻潪灝辨槸浠庣幇瀹炰笘鐣屾娊璞″嚭妯″瀷錛屽啀灝嗘ā鍨嬩笉鏂殑鎻愮偧鎶借薄錛屽睘鎬с佹柟娉曘佺被銆佺戶鎵褲佸眰嬈°佹鏋躲?/span>
 
緙栫▼灝辨槸涓涓笉鏂娊璞$殑榪囩▼銆傛垜鍐嶆鎶婁綔鑰呭湪絎竴绔犳湯鍐欎笅鐨勭粨璁烘妱鍦ㄨ繖閲岋紝浣滀負鏈鍚庣殑娉ㄨ剼銆?/span>
 
“浣滀負緙栫▼鑰咃紝鎴戜滑搴旇瀵硅繖綾誨彲鑳芥т繚鎸侀珮搴︽晱鎰燂紝璁炬硶浠庝腑璁懼埆鍑虹▼搴忎腑鐨勫熀鏈娊璞★紝鍩轟簬瀹冧滑鍘昏繘涓姝ユ瀯閫狅紝騫舵帹騫垮畠浠互鍒涘緩濞佸姏鏇村己澶х殑鎶借薄銆傚綋鐒訛紝榪欏茍涓嶆槸璇存誨簲璇ラ噰鐢ㄥ敖鍙兘鎶借薄鐨勬柟寮忓幓鍐欑▼搴忥紝紼嬪簭璁捐涓撳浠煡閬撳浣曟牴鎹伐浣滀腑鐨勬儏鍐碉紝鍘婚夋嫨鍚堥傜殑鎶借薄灞傛銆備絾鏄紝鑳藉熀浜庤繖縐嶆娊璞″幓鎬濊冪‘瀹炴槸鏈閲嶈鐨勶紝鍙湁榪欐牱鎵嶅彲鑳藉湪鏂扮殑涓婁笅鏂囦腑鍘誨簲鐢ㄥ畠浠傞珮闃惰繃紼嬬殑閲嶈鎬э紝灝卞湪浜庢垜浠兘鏄懼紡鍦扮敤紼嬪簭璁捐璇█鐨勮绱犲幓鎻忚堪榪欎簺鎶借薄錛屼嬌鎴戜滑鑳藉儚鎿嶄綔鍏朵粬璁$畻鍏冪礌涓鏍峰幓鎿嶄綔瀹冧滑銆?#8221;



cuigang 2008-03-18 21:57 鍙戣〃璇勮
]]>
鎴戠殑SICP涔犻絳旀錛?.11~1.13錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/12/44316.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Wed, 12 Mar 2008 15:10:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/12/44316.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/44316.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/12/44316.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/44316.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/44316.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-weight: bold;">1.11</span><br>閫掑綊璁$畻榪囩▼涓?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define func-recu<br>  (lambda(n)<br>    (cond ((< n </span><span style="color: #000000;">3</span><span style="color: #000000;">) n)<br>          (else (+ (func-recu (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>                   (* </span><span style="color: #000000;">2</span><span style="color: #000000;"> (func-recu (- n </span><span style="color: #000000;">2</span><span style="color: #000000;">)))<br>                   (* </span><span style="color: #000000;">3</span><span style="color: #000000;"> (func-recu (- n </span><span style="color: #000000;">3</span><span style="color: #000000;">))))))))</span></div> 榪唬璁$畻榪囩▼涓?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define func-iter<br>  (lambda(a b c n)<br>    (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> n </span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>        a<br>        (func-iter b c (+ (* </span><span style="color: #000000;">3</span><span style="color: #000000;"> a) (* </span><span style="color: #000000;">2</span><span style="color: #000000;"> b) c) (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">)))))<br><br>(define (func n) (func-iter </span><span style="color: #000000;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;"> n))</span></div> <br><span style="font-weight: bold;">1.12<br></span>涓枃鐗堝師棰樼炕璇戞湁璇紝搴斾負璁$畻pascal涓夎涓殑鍏冪礌銆?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #008000;">;</span><span style="color: #008000;">pas(n,k)</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">if (k=1) or (k=n), then pas(n,k) = 1</span><span style="color: #008000;"><br>;</span><span style="color: #008000;">else pas(n,k) = pas(n-1,k-1) + pas(n-1,k)</span><span style="color: #008000;"><br></span><span style="color: #000000;"><br>(define pas (lambda(n k)<br>              (if (or (</span><span style="color: #000000;">=</span><span style="color: #000000;"> k </span><span style="color: #000000;">1</span><span style="color: #000000;">) (</span><span style="color: #000000;">=</span><span style="color: #000000;"> k n))<br>                  </span><span style="color: #000000;">1</span><span style="color: #000000;"><br>                  (+ (pas (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">) (- k </span><span style="color: #000000;">1</span><span style="color: #000000;">))<br>                     (pas (- n </span><span style="color: #000000;">1</span><span style="color: #000000;">) k)))))<br></span></div> <br><span style="font-weight: bold;">1.13</span><br>涓枃鐗堝師棰樼炕璇戦仐婕?鎻愮ず 錛?#968;=(1-√5)/2<br>宸茬煡錛?#966;^2 = φ + 1, 閭d箞 φ^n = φ^(n-1) + φ^(n-2)</span><br>鍚岀悊錛?/span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ^2 = </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ + 1, </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">閭d箞 </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ^n = </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ^(n-1) + </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ^(n-2)<br>鍙?</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">φ-ψ = </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">(1+√5)/2 -</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"> (1-√5)/2</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"> = </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span><span style="font-size: 10pt;"><br><span style="font-size: 10pt;"><br>when n=0, Fib(0) = 0 = </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">(φ^0-ψ^0)/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span><br><span style="font-size: 10pt;"><span style="font-size: 10pt;">when n=1, Fib(1) = 1 = </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"> = (φ-ψ)/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"><br>when n>2, Fib(n) = Fib(n-1) + Fib(n-2) = (φ^(n-1)-ψ^(n-1))/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"> + (φ^(n-2)-ψ^(n-2))/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"><br>                 = ((</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">φ^(n-1)+(φ^(n-2))) - (</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ^(n-1)</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">+ψ^(n-2)))/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span><br><span style="font-size: 10pt;"><span style="font-size: 10pt;">                 = (</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">φ^n - </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ^n)/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5<br><br>鍙?-1< </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ</span></span> < 0, 鏁?-0.5< -1/</span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span></span><span style="font-size: 10pt; font-family: courier new;">< ψ^n/</span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span></span><span style="font-size: 10pt; font-family: courier new;"> < 1</span><span style="font-size: 10pt; font-family: courier new;">/</span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span></span><span style="font-size: 10pt; font-family: courier new;"></span><span style="font-size: 10pt; font-family: courier new;"> <0.5 , 鑰?</span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">φ^n</span></span></span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;">/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5</span></span></span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"> = </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">ψ^n/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5 + Fib(n)<br><br>鍙煡 |</span></span></span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;">φ^n</span></span></span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;">/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5 - Fib(n)| < 0.5, Fib(n)鏄渶鎺ヨ繎</span></span></span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span></span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;">φ^n</span></span></span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;">/</span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;">√5鐨勬暣鏁般?/span></span></span><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"></span></span></span><br><span style="font-size: 10pt; font-family: courier new;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><br><br></span></span></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/44316.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-12 23:10 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/12/44316.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.10錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/11/44218.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Tue, 11 Mar 2008 15:33:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/11/44218.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/44218.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/11/44218.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/44218.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/44218.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;">棣栧厛錛屽彲浠ュ啓鍑鴻繖涓嚱鏁扮殑鍑芥暟寮忥細<br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">            </span><span style="color: #000000;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">   y </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #008000;">;<br></span><span style="color: #000000;">f(x</span><span style="color: #000000;">,</span><span style="color: #000000;">y) </span><span style="color: #000000;">=</span><span style="color: #000000;">    2y</span><span style="color: #000000;">,</span><span style="color: #000000;">  x </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #008000;">;<br></span><span style="color: #000000;">            </span><span style="color: #000000;">2</span><span style="color: #000000;">,</span><span style="color: #000000;">   y </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #008000;">;<br></span><span style="color: #000000;">            f(x-</span><span style="color: #000000;">1</span><span style="color: #000000;">,</span><span style="color: #000000;"> f(x</span><span style="color: #000000;">,</span><span style="color: #000000;"> y-</span><span style="color: #000000;">1</span><span style="color: #000000;">))</span><span style="color: #008000;">;</span></div> <br>閭d箞錛屽浜?f(0,n), n>=0<br>褰?nbsp;  n >= 1 鏃訛紝 f(0,n) = 2n 錛?br>鑰屽綋 n =  0 鏃訛紝 f(0,0) = 0 = 2*0錛?涔熸弧瓚?2n 錛?br>鏁?f(0,n) = 2n, n>=0.<br><br>瀵逛簬f(1,n), n>=1<br>褰?n > 1 鏃訛紝鏈?f(1,n) = f(0, f(1, n-1)) = 2*f(1,n-1),<br>璁?f(1,n) = 2^n<br>if   n = 1,    f(1,1)    = 2 = 2^1<br>when n > 1, if f(1,n-1)  = 2^(n-1)<br>then f(1,n) = 2*f(1,n-1) = 2*(2^(n-1)) = 2^n<br>鏁?f(1,n) = 2^n, n>0.<br><br>瀵逛簬f(2,n), n>0<br>if n > 1 ,then f(2,n) = f(1, f(2, n-1)) = 2^f(2,n-1),<br>璁?f(2,n) = 2^(2^(... (n 涓?2)<br>if   n = 1, then f(2,1)  = 2<br>when n > 1, if f(2, n-1) = 2^(2^(...        (n-1)<br>then f(2,n) = 2^f(2,n-1) = 2^(2^(<br><br>榪欐牱鎴戜滑瀵逛簬 (A 1 10) = 2^10 = 1024, (A 2 4) = 2^(2^(2^2)) = 2^16 = 65536<br>鑰?(A 3 3) = (A 2 A(3 2)) = A(2 A(2 A(2 1))) = (A 2 4) = 2^16 = 65536<br><br>(f n) = (A 0 n) = 2n<br>(g n) = (A 1 n) = 2^n<br>(h n) = (A 2 n) = 2^(2^(...      (n涓?)<br><br>---------------------------------------------<br>鍦ㄧ綉涓婂彲浠ユ壘鍒板叧浜?Ackermann 鍑芥暟鐨勮璁猴紝涓昏鏄拡瀵硅繖涓弻閫掑綊濡備綍鐢ㄨ凱浠f潵瀹炵幇錛孉ckermann 鍑芥暟鏄?<font size="-1">寰峰浗鏁板瀹禬.Ackermann</font> 鍦?928騫存彁鍑虹殑銆傚湪 WikiPedia 鑻辨枃鐗堜笂鍙互鎼滅儲 Ackermann function 璇嶆潯錛屾湁璇︾粏浠嬬粛錛屼笉榪囪繖涓狝ckermann function 鐣ユ湁涓嶅悓銆傚涓嬪浘錛?br><img alt="" src="http://www.shnenglu.com/images/cppblog_com/cuigang/0ae4053de098cc9554752b190a38bc56.png" height="85" width="490"><br><br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/44218.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-11 23:33 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/11/44218.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.9錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/11/44213.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Tue, 11 Mar 2008 13:53:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/11/44213.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/44213.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/11/44213.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/44213.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/44213.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; font-family: courier new;">寰堟樉鐒訛紝絎竴涓槸閫掑綊鐨勶紝絎簩涓槸榪唬鐨勩?br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(+ </span><span style="color: #000000;">4</span><span style="color: #000000;"> </span><span style="color: #000000;">5</span><span style="color: #000000;">)<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">4</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">5</span><span style="color: #000000;"> (inc (+ (dec </span><span style="color: #000000;">4</span><span style="color: #000000;">) </span><span style="color: #000000;">5</span><span style="color: #000000;">)))<br>(inc (+ </span><span style="color: #000000;">3</span><span style="color: #000000;"> </span><span style="color: #000000;">5</span><span style="color: #000000;">))<br>(inc (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">3</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">5</span><span style="color: #000000;"> (inc (+ </span><span style="color: #000000;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">5</span><span style="color: #000000;">))))<br>(inc (inc (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">5</span><span style="color: #000000;"> (inc (+ </span><span style="color: #000000;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">5</span><span style="color: #000000;">)))))<br>(inc (inc (inc (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">5</span><span style="color: #000000;"> (inc (+ </span><span style="color: #000000;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">5</span><span style="color: #000000;">))))))<br>(inc (inc (inc (inc (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">5</span><span style="color: #000000;"> (inc (+ (dec </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">5</span><span style="color: #000000;">)))))))<br>(inc (inc (inc (inc </span><span style="color: #000000;">5</span><span style="color: #000000;">))))<br>(inc (inc (inc </span><span style="color: #000000;">6</span><span style="color: #000000;">)))<br>(inc (inc </span><span style="color: #000000;">7</span><span style="color: #000000;">))<br>(inc </span><span style="color: #000000;">8</span><span style="color: #000000;">)<br></span><span style="color: #000000;">9</span><span style="color: #000000;"><br><br>(+ </span><span style="color: #000000;">4</span><span style="color: #000000;"> </span><span style="color: #000000;">5</span><span style="color: #000000;">)<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">4</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">5</span><span style="color: #000000;"> (+ </span><span style="color: #000000;">3</span><span style="color: #000000;"> </span><span style="color: #000000;">6</span><span style="color: #000000;">))<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">3</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">6</span><span style="color: #000000;"> (+ </span><span style="color: #000000;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">7</span><span style="color: #000000;">))<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">2</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">7</span><span style="color: #000000;"> (+ </span><span style="color: #000000;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">8</span><span style="color: #000000;">))<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">8</span><span style="color: #000000;"> (+ </span><span style="color: #000000;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">9</span><span style="color: #000000;">))<br>(if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">) </span><span style="color: #000000;">9</span><span style="color: #000000;"> (+ (dec </span><span style="color: #000000;">0</span><span style="color: #000000;">) (inc </span><span style="color: #000000;">9</span><span style="color: #000000;">)))<br></span><span style="color: #000000;">9</span></div> <br><br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/44213.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-11 21:53 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/11/44213.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.8錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/11/44211.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Tue, 11 Mar 2008 13:24:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/11/44211.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/44211.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/11/44211.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/44211.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/44211.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;"><span style="font-family: courier new;">閲囩敤1.7涓殑鍙樺寲鐜囦負緇堟媯嫻嬨?/span><br style="font-family: courier new;"><br style="font-family: courier new;"> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%; font-family: courier new;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (cube-root x)<br>  (cube-root-iter x </span><span style="color: #000000;">1.0</span><span style="color: #000000;"> x))<br><br>(define (cube-root-iter last-guess guess x)<br>  (if (enuf? last-guess guess)<br>      guess<br>      (cube-root-iter guess (improve guess x) x)))<br><br>(define (enuf? x y)<br>  (< (/ (abs (- x y)) y) </span><span style="color: #000000;">0.001</span><span style="color: #000000;">))<br><br>(define improve (lambda (y x)<br>                  (/ (+ (/ x (* y y)) (* </span><span style="color: #000000;">2</span><span style="color: #000000;"> y)) </span><span style="color: #000000;">3</span><span style="color: #000000;">)))<br></span></div> <br></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/44211.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-11 21:24 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/11/44211.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.7錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/11/44125.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Mon, 10 Mar 2008 16:07:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/11/44125.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/44125.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/11/44125.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/44125.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/44125.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt;"><span style="font-family: courier new;">瀵逛簬姝f枃涓殑 good-enough? 璋撹瘝錛岃鎵姹?x 鐨勭湡瀹炲鉤鏂規牴涓?xt錛岄偅涔堟垜浠殑渚濇嵁鏄綋 guess 浠?1 瓚嬪悜涓?xt 鐨勫鉤鏂瑰樊 灝忎簬 c(0.001) 鏃訛紝guess 榪戜技浜?xt銆傚疄闄呭綋 xt^2 涔熷氨鏄?x 瓚沖灝忔椂錛?guess 浼?閫愭笎紼沖畾鍦?√c 闄勮繎銆備粠涓嬮潰瀹為獙鍙互鐪嬪嚭錛?br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">> (sqrt (square </span><span style="color: #000000;">0.1</span><span style="color: #000000;">))<br></span><span style="color: #000000;">0.10032578510960607</span><span style="color: #000000;"><br>> (sqrt (square </span><span style="color: #000000;">0.05</span><span style="color: #000000;">))<br></span><span style="color: #000000;">0.054237622808967656</span><span style="color: #000000;"><br>> (sqrt (square </span><span style="color: #000000;">0.01</span><span style="color: #000000;">))<br></span><span style="color: #000000;">0.03230844833048122</span><span style="color: #000000;"><br>> (sqrt (square </span><span style="color: #000000;">0.005</span><span style="color: #000000;">))<br></span><span style="color: #000000;">0.031515954454847304</span><span style="color: #000000;"><br>> (sqrt (square </span><span style="color: #000000;">0.001</span><span style="color: #000000;">))<br></span><span style="color: #000000;">0.031260655525445276</span><span style="color: #000000;"><br>> (sqrt (square </span><span style="color: #000000;">0.0001</span><span style="color: #000000;">))<br></span><span style="color: #000000;">0.03125010656242753</span><span style="color: #000000;"><br>> <br></span></div>  <br>鍥犱負 guess^2 < c + x , 褰?x < c 鏃訛紝guess 灝辨洿澶氱殑渚濊禆浜?c 浜嗐?br><br>瀵逛簬鐗瑰埆澶х殑鏁幫紝鐢變簬嫻偣鏁板湪鐗瑰埆澶ф椂錛岀鏁fч潪甯告槑鏄撅紝鐩擱偦鐨勪袱涓暟涔嬮棿鐨勫樊璺濅細闈炲父澶э紝瀵艱嚧 |guess^2 - x| 濮嬬粓 澶т簬 c錛岃綆椾究榪涘叆浜?鏃犻檺寰幆銆?br><br>姣斿璁$畻 (sqrt 1e300)<br><br>浣跨敤鍙樺寲鐜囨敼榪涘悗鐨勪唬鐮佸涓嬶細<br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (sqrt-new x)<br>  (sqrt-iter-new x </span><span style="color: #000000;">1.0</span><span style="color: #000000;"> x))<br><br>(define (sqrt-iter-new s1 s2 x)<br>  (if (enuf-new? s1 s2)<br>      s2<br>      (sqrt-iter-new s2 (improve s2 x) x)))<br><br>(define (enuf-new? s1 s2)<br>  (< (/ (abs (- s1 s2)) s1) </span><span style="color: #000000;">0.001</span><span style="color: #000000;">))</span></div> <br>鍙互嫻嬬畻鍑犱釜鏁幫紝楠岃瘉緇撴灉榪樻槸姣旇緝濂界殑銆?br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">> (sqrt-new (square </span><span style="color: #000000;">1e150</span><span style="color: #000000;">))<br></span><span style="color: #000000;">1.0000000000084744e+150</span><span style="color: #000000;"><br>> (sqrt-new (square </span><span style="color: #000000;">1e-150</span><span style="color: #000000;">))<br></span><span style="color: #000000;">1.0000000000084744e-150</span></div> <br><br style="font-family: courier new;"></span></span> <img src ="http://www.shnenglu.com/cuigang/aggbug/44125.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-11 00:07 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/11/44125.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.6錛?/title><link>http://www.shnenglu.com/cuigang/archive/2008/03/09/44047.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Sun, 09 Mar 2008 15:12:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2008/03/09/44047.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/44047.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2008/03/09/44047.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/44047.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/44047.html</trackback:ping><description><![CDATA[<span style="font-family: courier new; font-size: 10pt;"><span style="font-family: 寰蔣闆呴粦;"></span>浼氶掑綊鐩村埌鍫嗘爤婧㈠嚭銆?br>鍘熷洜鏄?鍦?new-if 榪樻病鏈夊睍寮涓?cond special forms 鏃訛紝else-clause 瀛愬紡宸茬粡闄峰叆浜嗘棤闄愰掑綊銆?鍋氫簡浠ヤ笅瀹為獙錛屽彲浠ラ獙璇?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">(define (new-if pred thenc elsec)<br>  (cond (pred thenc)<br>        (else elsec)))<br><br>(define (iter x y)<br>  (new-if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> x y)<br>          </span><span style="color: #000000;">0</span><span style="color: #000000;"><br>          (iter (+ x </span><span style="color: #000000;">1</span><span style="color: #000000;">) y)))<br><br>(define (iter-if x y)<br>  (if (</span><span style="color: #000000;">=</span><span style="color: #000000;"> x y)<br>      </span><span style="color: #000000;">0</span><span style="color: #000000;"><br>      (iter-if (+ x </span><span style="color: #000000;">1</span><span style="color: #000000;">) y)))<br><br>(define (iter-cond x y)<br>  (cond ((</span><span style="color: #000000;">=</span><span style="color: #000000;"> x y) </span><span style="color: #000000;">0</span><span style="color: #000000;">)<br>        (else (iter-cond (+ x </span><span style="color: #000000;">1</span><span style="color: #000000;">) y))))</span></div> <br>瀵逛簬 (iter 1 10), (iter-if 1 10), (iter-cond 1 10)<br>鍏朵腑 iter 浼?瀵艱嚧鍫嗘爤婧㈠嚭錛岃?iter-cond 鍜?iter-if 騫朵笉浼氥?br><br>姝ら鍚?.5<br>鍦?.5涓紝鐢變簬搴旂敤搴忕殑鍘熷洜錛屽湪 test 琛ㄨ揪寮?榪樻病鏈夊睍寮涓?if 鐗規畩褰㈠紡錛坰pecial forms錛夋椂錛?(p)宸茬粡闄峰叆浜嗘棤闄愰掑綊銆?br></span><br> <img src ="http://www.shnenglu.com/cuigang/aggbug/44047.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2008-03-09 23:12 <a href="http://www.shnenglu.com/cuigang/archive/2008/03/09/44047.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑SICP涔犻絳旀錛?.1~1.5錛?/title><link>http://www.shnenglu.com/cuigang/archive/2007/12/26/39635.html</link><dc:creator>cuigang</dc:creator><author>cuigang</author><pubDate>Tue, 25 Dec 2007 16:19:00 GMT</pubDate><guid>http://www.shnenglu.com/cuigang/archive/2007/12/26/39635.html</guid><wfw:comment>http://www.shnenglu.com/cuigang/comments/39635.html</wfw:comment><comments>http://www.shnenglu.com/cuigang/archive/2007/12/26/39635.html#Feedback</comments><slash:comments>13</slash:comments><wfw:commentRss>http://www.shnenglu.com/cuigang/comments/commentRss/39635.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/cuigang/services/trackbacks/39635.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt">1.1 <br /><br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-family: courier new; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">10</span><span style="color: #000000">,</span><span style="color: #000000">12</span><span style="color: #000000">,</span><span style="color: #000000">8</span><span style="color: #000000">,</span><span style="color: #000000">3</span><span style="color: #000000">,</span><span style="color: #b6b6b6">10</span><span style="color: #000000"> <span style="color: #ff0000">6</span>,</span><span style="color: #000000">a</span><span style="color: #000000">,</span><span style="color: #000000">b</span><span style="color: #000000">,</span><span style="color: #000000">19</span><span style="color: #000000">,</span><span style="color: #000000">#f</span><span style="color: #000000">,</span><span style="color: #000000">4</span><span style="color: #000000">,</span><span style="color: #000000">16</span><span style="color: #000000">,</span><span style="color: #000000">6</span><span style="color: #000000">,</span><span style="color: #000000">16</span></div><span style="font-family: courier new"><br />1.2</span><br /><br style="font-family: courier new" /><span style="font-family: courier new"> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">(/(+ </span><span style="color: #000000">5</span><span style="color: #000000"> </span><span style="color: #000000">4</span><span style="color: #000000"> (- </span><span style="color: #000000">2</span><span style="color: #000000"> (- </span><span style="color: #000000">3</span><span style="color: #000000"> (+ </span><span style="color: #000000">6</span><span style="color: #000000">(/ </span><span style="color: #000000">4</span><span style="color: #000000"> </span><span style="color: #000000">5</span><span style="color: #000000">)))))(* </span><span style="color: #000000">3</span><span style="color: #000000"> (- </span><span style="color: #000000">6</span><span style="color: #000000"> </span><span style="color: #000000">2</span><span style="color: #000000">)(- </span><span style="color: #000000">2</span><span style="color: #000000"> </span><span style="color: #000000">7</span><span style="color: #000000">)))</span></div><br />or<br /><br style="font-family: courier new" /></span><span style="font-family: courier new"> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">(/(+ </span><span style="color: #000000">5</span><span style="color: #000000"> </span><span style="color: #000000">4</span><span style="color: #000000"> (- </span><span style="color: #000000">2</span><span style="color: #000000"> (- </span><span style="color: #000000">3</span><span style="color: #000000"> (+ </span><span style="color: #000000">6</span><span style="color: #000000"> </span><span style="color: #000000">4</span><span style="color: #000000">/</span><span style="color: #000000">5</span><span style="color: #000000">))))(* </span><span style="color: #000000">3</span><span style="color: #000000"> (- </span><span style="color: #000000">6</span><span style="color: #000000"> </span><span style="color: #000000">2</span><span style="color: #000000">)(- </span><span style="color: #000000">2</span><span style="color: #000000"> </span><span style="color: #000000">7</span><span style="color: #000000">)))</span></div></span><br style="font-family: courier new" /><span style="font-family: courier new">1.3<br /><br />榪欎釜闂涓枃鐗堢殑緲昏瘧鏄敊鐨勶紝鍙傜湅鍘熸枃鏄眰騫蟲柟鍜岃屼笉鏄?#8220;鍜?#8221;銆?br /><br /></span> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-family: courier new; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">(define (square(x)(* x x)))<br />(define (max x y)(if (< x y) y x))<br />(define (func x y z)<br />  (+ (square (max x y))<br />     (square (max (min x y) z))))</span></div><br style="font-family: courier new" /><span style="font-family: courier new">1.4<br /><br style="font-family: courier new" /></span><span style="font-family: courier new"> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">a+|b| </span></div></span><br style="font-family: courier new" /><span style="font-family: courier new"><=><br /><br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080">1</span> <span style="color: #008000">#</span><span style="color: #008000"> in python</span><span style="color: #008000"><br /></span><span style="color: #008080">2</span> <span style="color: #008000"></span><span style="color: #0000ff">def</span><span style="color: #000000"> a_plus_abs_b(a,b):<br /></span><span style="color: #008080">3</span> <span style="color: #000000">    </span><span style="color: #0000ff">if</span><span style="color: #000000"> b</span><span style="color: #000000">></span><span style="color: #000000">0 :<br /></span><span style="color: #008080">4</span> <span style="color: #000000">        x </span><span style="color: #000000">=</span><span style="color: #000000"> a </span><span style="color: #000000">+</span><span style="color: #000000"> b<br /></span><span style="color: #008080">5</span> <span style="color: #000000">    </span><span style="color: #0000ff">else</span><span style="color: #000000">:<br /></span><span style="color: #008080">6</span> <span style="color: #000000">        x </span><span style="color: #000000">=</span><span style="color: #000000"> a </span><span style="color: #000000">-</span><span style="color: #000000"> b<br /></span><span style="color: #008080">7</span> <span style="color: #000000">    </span><span style="color: #0000ff">return</span><span style="color: #000000"> x</span></div><br style="font-family: courier new" /></span><span style="font-family: courier new"></span><span style="font-family: courier new"></span><span style="font-family: courier new">1.5<br /><br style="font-family: courier new" /></span><span style="font-family: courier new"></span><strike><span style="color: #adb8c6">鍦ㄧ綉涓婄湅浜嗗緢澶氱瓟妗堬紝閮借涓?#8220;搴旂敤搴?#8221;鐨勫疄鐜頒細瀵艱嚧姝誨驚鐜紝鎴戦潪甯稿洶鎯戙傚弽澶嶇湅浜嗕腑鏂囩増鍜岃嫳鏂囩増錛岃寰楀ぇ瀹惰繖鏍瘋涓哄彲鑳芥槸涔︿腑璇磍isp鐨勫疄鐜版槸“搴旂敤搴?#8221;錛岃屽湪scheme涓窇榪欐浠g爜浼氭寰幆錛屽氨鍏堝叆涓轟富鐨勮涓?#8220;搴旂敤搴?#8221;鐨勫疄鐜頒細姝誨驚鐜傚叾瀹炲鐓ф鏂囷紝鎴戜滑鍙互鐪嬪埌“姝e垯搴?#8221;鍋滄灞曞紑鐨勬潯浠舵槸“鍙寘鍚熀鏈繍綆楃鐨勮〃杈懼紡”錛岃屽浜?/span><br style="color: #adb8c6" /><br style="color: #adb8c6" /></strike> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-family: courier new; color: #adb8c6; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><strike>(define (p) (p))</strike></div><br style="color: #adb8c6" /><strike><span style="color: #adb8c6">鏄棤璁哄浣曚篃娌℃硶瀹屽叏灞曞紑鐨勶紝鍥犱負瀹冧細涓嶆柇閫掑綊錛屾墍浠?#8220;姝e垯搴?#8221;鎵嶄細姝誨驚鐜?/span><br style="color: #adb8c6" /><br style="color: #adb8c6" /><span style="color: #adb8c6">鑰屽浜?#8220;搴旂敤搴?#8221;鐨勫疄鐜幫紝鍒欎細榪欐牱灞曞紑</span></strike><br style="color: #adb8c6" /><br style="color: #adb8c6" /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-family: courier new; color: #adb8c6; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><strike>(test 0 (p))<br />(if (= 0 0) 0 (p))<br />(if #t 0 (p))<br /><br />; 0</strike></div><br style="font-family: courier new" /><span style="font-family: courier new">瑙e喅榪欎釜闂涓昏鏄?#8220;姝e垯搴?#8221;錛圢ormal order錛変互鍙?#8220;搴旂敤搴?#8221;錛圓pplicative order錛夊睍寮涓涓粍鍚堝紡鐨勮鍒欙紝浠旂粏鐮旂┒浜哅IT 6.001璇劇▼璁蹭箟錛岀綉涓婄殑鍚勭絳旀錛屼互鍙婁腑鑻辨枃鐗堛傛垜璁や負錛屾鍒欏簭浠ョ被浼煎箍搴︿紭鍏堢殑鏂瑰紡榪涜灞曞紑銆傝屽簲鐢ㄥ簭浼樺厛璁$畻瀛愯〃杈懼紡錛岀被浼間笌娣卞害浼樺厛銆傞偅涔堝浜庤繖涓棶棰橈紝</span></span><span style="font-family: courier new; font-size: 10pt">姝e垯搴?/span><span style="font-size: 10pt"><span style="font-family: courier new">浼氬睍寮涓?/span><br style="font-family: courier new" /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-family: courier new; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000">=</span><span style="color: #000000">> (if (</span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">) </span><span style="color: #000000">0</span><span style="color: #000000"> (p))<br /></span><span style="color: #000000">=</span><span style="color: #000000">> (if #t </span><span style="color: #000000">0</span><span style="color: #000000"> (p))<br /></span></div><span style="font-family: courier new">鎺ョ潃錛岀敱浜庤繖鏄竴涓猧f鐨剆pecial form錛堢壒孌婂艦寮忥級錛屽氨浼氳灞曞紑涓?/span><br style="font-family: courier new" /><span style="font-family: courier new">0</span><br style="font-family: courier new" /><span style="font-family: courier new">鑰屽簲鐢ㄥ簭錛岀敱浜?p)涓鐩村彲浠ラ掑綊浠f崲錛屼粠涓寮濮嬪氨浼氳繘鍏ヤ竴涓棤闄愰掑綊涓幓銆?/span><br />綆璦涔嬶紝鐢變簬搴旂敤搴忕殑鍘熷洜錛屽湪 test 琛ㄨ揪寮?榪樻病鏈夊睍寮涓?if 鐗規畩褰㈠紡錛坰pecial forms錛夋椂錛?(p)宸茬粡闄峰叆浜嗘棤闄愰掑綊銆?<br /><br /></span><img src ="http://www.shnenglu.com/cuigang/aggbug/39635.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/cuigang/" target="_blank">cuigang</a> 2007-12-26 00:19 <a href="http://www.shnenglu.com/cuigang/archive/2007/12/26/39635.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>璇籗ICP鏈夋劅http://www.shnenglu.com/cuigang/archive/2007/12/25/39623.htmlcuigangcuigangTue, 25 Dec 2007 13:48:00 GMThttp://www.shnenglu.com/cuigang/archive/2007/12/25/39623.htmlhttp://www.shnenglu.com/cuigang/comments/39623.htmlhttp://www.shnenglu.com/cuigang/archive/2007/12/25/39623.html#Feedback0http://www.shnenglu.com/cuigang/comments/commentRss/39623.htmlhttp://www.shnenglu.com/cuigang/services/trackbacks/39623.html鎬濇兂閮借棌鍦╨isp紼嬪簭鐨勫眰灞傛嫭鍙蜂腑鍚楋紵

1 (define (abs x)
2     (if (< x 0)
3         (- x)
4         (x)))




cuigang 2007-12-25 21:48 鍙戣〃璇勮
]]>
久久er热视频在这里精品| 99久久精品免费国产大片| 无码人妻久久一区二区三区免费丨| av色综合久久天堂av色综合在| 久久狠狠高潮亚洲精品| 四虎国产永久免费久久| 伊人久久精品影院| 久久香蕉一级毛片| 国产69精品久久久久APP下载 | 亚洲AV无一区二区三区久久| 国内精品伊人久久久久AV影院| 99久久精品无码一区二区毛片 | 国内精品久久国产大陆| 久久久免费观成人影院| 亚洲精品tv久久久久久久久| 精品视频久久久久| 99久久人妻无码精品系列蜜桃 | 久久91精品国产91久久小草| 亚洲午夜无码久久久久小说 | 亚洲精品国产综合久久一线| 久久久久成人精品无码中文字幕 | 日韩精品久久久久久| 香蕉久久夜色精品国产尤物| 四虎国产永久免费久久| 久久66热人妻偷产精品9| 久久人妻无码中文字幕| 久久久久99精品成人片牛牛影视 | 久久亚洲日韩看片无码| 久久精品国产一区二区| 91久久九九无码成人网站| 久久午夜羞羞影院免费观看| 久久综合亚洲色HEZYO社区| 亚洲精品NV久久久久久久久久| 一级做a爱片久久毛片| 成人资源影音先锋久久资源网| 一本色道久久HEZYO无码| 久久九九兔免费精品6| 伊人热热久久原色播放www| 亚洲va久久久久| 久久久久久国产精品无码下载| 久久免费99精品国产自在现线|