Skip to content

Commit 711d302

Browse files
committed
Add implementation of exercise 3-68
1 parent 79c2492 commit 711d302

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

README.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
习题完成情况:
2626
- 章节一: 43/46
2727
- 章节二: 88/97
28-
- 章节三: 61/82
28+
- 章节三: 62/82
2929
- 章节四: TODO
3030
- 章节五: TODO
3131
* 运行

chapter3/exercise3-68.org

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#+LATEX_CLASS: ramsay-org-article
2+
#+LATEX_CLASS_OPTIONS: [oneside,A4paper,12pt]
3+
#+AUTHOR: Ramsay Leung
4+
5+
#+DATE: 2025-07-30 Wed 21:33
6+
7+
Louis 的方案不可行,因为 Louis 的方案没有使用 =cons-stream= 创建延误执行的 =delayed-object=, 这意味着:
8+
9+
#+begin_src scheme
10+
(define (pairs s t)
11+
(interleave
12+
(stream-map (lambda (x) (list (stream-car s) x))
13+
t)
14+
;; 立即执行,而非延迟执行
15+
(pairs (stream-cdr s) (stream-cdr t)
16+
)))
17+
#+end_src
18+
19+
=interleave= 会交替执行两个流,而执行 =pairs= 的时候,因为不是 =delayed-object= 就会马上执行,就会无限递归,直到 =StackOverflow=

0 commit comments

Comments
 (0)