From 1ea1a8ab765b09f8b9b63e9fb36382165a1ab056 Mon Sep 17 00:00:00 2001 From: Darcy Shen Date: Tue, 19 Mar 2024 16:19:29 +0800 Subject: [PATCH] =?UTF-8?q?SICP=2006:=20=E4=BB=A3=E7=A0=81=E6=B8=85?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SICP/code06.tm | 268 +++++++++++++++++++++++++++++++++++++++++++++++++ SICP/index.tm | 4 + 2 files changed, 272 insertions(+) create mode 100644 SICP/code06.tm diff --git a/SICP/code06.tm b/SICP/code06.tm new file mode 100644 index 0000000..0a68323 --- /dev/null +++ b/SICP/code06.tm @@ -0,0 +1,268 @@ + + +> + +<\body> + \<#56FE\>> + + <\session|scheme|default> + <\folded-io|Scheme] > + (define (plot l) (stree-\tree l)) + <|folded-io> + plot + + + <\folded-io|Scheme] > + (plot `(frac 1 2)) + <|folded-io> + > + + + <\folded-io|Scheme] > + (plot `(point 0 0)) + <|folded-io> + > + + + <\folded-io|Scheme] > + (plot `(graphics (point -5 -5) (point 5 5))) ; quasiquote ` + <|folded-io> + |>> + + + <\folded-io|Scheme] > + (plot `(graphics (point ,(+ 1 2) ,(+ 1 3)) (point 0 0))) + <|folded-io> + |gr-grid-old||1>|gr-edit-grid-aspect|||>|gr-edit-grid||gr-edit-grid-old||1>||>>> + + + <\folded-io|Scheme] > + (plot `(graphics (point 0 0) (point 1 1) (line (point 0 0) (point 1 + 1))))) + <|folded-io> + |||>>> + + + <\unfolded-io|Scheme] > + (plot `(cline (point 0 0) (point 3 0) (point 0 4))) + <|unfolded-io> + ||>> + + + <\unfolded-io|Scheme] > + (kbd-map ("d i a n var" (insert (utf8-\cork "\<#70B9\>")))) + <|unfolded-io> + ("d i a n tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("h t var" (insert (utf8-\cork "\<#7ED8\>\<#56FE\>")))) + <|unfolded-io> + ("h t tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("t u var" (insert (utf8-\cork "\<#56FE\>")))) + <|unfolded-io> + ("t u tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("s j x var" (insert (utf8-\cork + "\<#4E09\>\<#89D2\>\<#5F62\>")))) + <|unfolded-io> + ("s j x tab") + + + <\unfolded-io|Scheme] > + (kbd-map ("z s j x var" (insert (utf8-\cork + "\<#6B63\>\<#4E09\>\<#89D2\>\<#5F62\>")))) + <|unfolded-io> + ("z s j x tab") + + + <\unfolded-io|Scheme] > + (define (\<#7ED8\>\<#56FE\> l) (stree-\tree l)) + <|unfolded-io> + \<#7ED8\>\<#56FE\> + + + <\unfolded-io|Scheme] > + (define (\<#70B9\> x y) `(point ,x ,y)) + <|unfolded-io> + \<#70B9\> + + + <\folded-io|Scheme] > + (define (\<#56FE\> . objects) + + \ \ (cond ((nlist? objects) '(graphics "" "")) + + \ \ \ \ \ \ \ \ ((== objects '()) '(graphics "" "")) + + \ \ \ \ \ \ \ \ (else `(graphics "" ,@objects)))) + <|folded-io> + \<#56FE\> + + + <\folded-io|Scheme] > + (\<#7ED8\>\<#56FE\> (\<#56FE\> (\<#70B9\> 1 1) (\<#70B9\> 2 2))) + <|folded-io> + |1>|gr-grid-old||1>|gr-edit-grid-aspect|||>|gr-edit-grid||1>|gr-edit-grid-old||1>|gr-frame|>|magnify|3.0||>>> + + + <\unfolded-io|Scheme] > + (define (triangle x y z) + + \ \ `(cline ,x ,y ,z)) + <|unfolded-io> + \<#4E09\>\<#89D2\>\<#5F62\> + + + <\input|Scheme] > + (define (\<#4E09\>\<#89D2\>\<#5F62\> x y z) (triangle x y z)) + + + <\unfolded-io|Scheme] > + (\<#7ED8\>\<#56FE\> (\<#4E09\>\<#89D2\>\<#5F62\> (\<#70B9\> 0 0 ) + (\<#70B9\> 0 3) (\<#70B9\> 4 0))) + <|unfolded-io> + ||>> + + + <\unfolded-io|Scheme] > + (car (cdr (cdr (\<#70B9\> 1 2)))) ; third + <|unfolded-io> + 2 + + + <\unfolded-io|Scheme] > + (car (cdr (\<#70B9\> 1 2))) ; second + <|unfolded-io> + 1 + + + <\unfolded-io|Scheme] > + (list-ref (list 1 2 3 4 5) 1) + <|unfolded-io> + 2 + + + <\unfolded-io|Scheme] > + (define (\<#6B63\>\<#4E09\>\<#89D2\>\<#5F62\> A \<#8FB9\>\<#957F\>) + + \ \ (\<#4E09\>\<#89D2\>\<#5F62\> + + \ \ \ \ \ \ \ A + + \ \ \ \ \ \ \ (\<#70B9\> (+ \<#8FB9\>\<#957F\> (second A))) + + \ \ \ \ \ \ \ \ \ \ \ (third A)) + + \ \ \ \ \ \ \ (\<#70B9\> (+ (* 0.5 \<#8FB9\>\<#957F\>) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ (second A)) + + \ \ \ \ \ \ \ \ \ \ \ (+ (third A) (* (sqrt 0.75) + \<#8FB9\>\<#957F\>)))))) + <|unfolded-io> + \<#6B63\>\<#4E09\>\<#89D2\>\<#5F62\> + + + <\unfolded-io|Scheme] > + (\<#7ED8\>\<#56FE\> (\<#6B63\>\<#4E09\>\<#89D2\>\<#5F62\> (\<#70B9\> 0 + 0) 3)) + <|unfolded-io> + + + + <\unfolded-io|Scheme] > + (define (point x y) `(point ,x ,y)) + <|unfolded-io> + point + + + <\unfolded-io|Scheme] > + (point 1 2) =\ (point "1" "2") + <|unfolded-io> + (point 1 2) + + + <\unfolded-io|Scheme] > + (number? 1) + <|unfolded-io> + #t + + + <\unfolded-io|Scheme] > + (number-\string 1) + <|unfolded-io> + (number-\string 1) + + + <\unfolded-io|Scheme] > + \; + <|unfolded-io> + x-\string + + + <\unfolded-io|Scheme] > + (define (draw x) + + \ \ (define (x-\string x) + + \ \ \ \ \ \ (if (number? x) + + \ \ \ \ \ \ \ \ (number-\string x) + + \ \ \ \ \ \ \ \ x)) + + \ \ (define (draw-inner x) + + \ \ \ \ (if (eq? () x) () + + \ \ \ \ \ \ (cons (x-\string (car x)) + + \ \ \ \ \ \ \ \ \ \ \ \ (draw-inner (cdr x))))) + + \ \ (stree-\tree (draw-inner x))) + <|unfolded-io> + draw + + + <\unfolded-io|Scheme] > + (draw `(point 1 1)) + <|unfolded-io> + > + + + <\input|Scheme] > + \; + + + + +<\initial> + <\collection> + + + + + + +<\references> + <\collection> + > + + + +<\auxiliary> + <\collection> + <\associate|toc> + |math-font-series||\<#7ED8\>\<#56FE\>> + |.>>>>|> + + + + \ No newline at end of file diff --git a/SICP/index.tm b/SICP/index.tm index 61c33c5..572c36b 100644 --- a/SICP/index.tm +++ b/SICP/index.tm @@ -24,6 +24,10 @@ \<#76EE\>\<#6807\>\<#90AE\>\<#7BB1\>\<#FF1A\>shenda AT ustc.edu + \<#7B2C\>6\<#8BFE\>\<#FF1A\>\<#7B97\>\<#6CD5\>\<#7684\>\<#65F6\>\<#7A7A\>\<#590D\>\<#6742\>\<#5EA6\>\<#FF08\>\<#4E60\>\<#9898\>\<#8BFE\>\<#FF09\> + + \<#4EE3\>\<#7801\>\<#FF1A\>\<#7801\>\<#6E05\>\<#5355\>06|code06.tm> + \<#7B2C\>5\<#8BFE\>\<#FF1A\>\<#7B97\>\<#6CD5\>\<#7684\>\<#65F6\>\<#7A7A\>\<#590D\>\<#6742\>\<#5EA6\> \<#8BB2\>\<#4E49\>\<#FF1A\>\<#4E92\>\<#5F0F\>\<#8BB2\>\<#4E49\>05|https://gitee.com/XmacsLabs/interactive-sicp/raw/main/course05.tm>