File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 25
25
习题完成情况:
26
26
- 章节一: 43/46
27
27
- 章节二: 88/97
28
- - 章节三: 54 /82
28
+ - 章节三: 55 /82
29
29
- 章节四: TODO
30
30
- 章节五: TODO
31
31
* 运行
Original file line number Diff line number Diff line change 3
3
(require "exercise3-50.rkt " )
4
4
(require "infinite-stream.rkt " )
5
5
6
- (define (mul-stream s1 s2)
6
+ (define (mul-streams s1 s2)
7
7
(map-stream * s1 s2))
8
8
9
- (define factorials (cons-stream 1 (mul-stream (stream-cdr integers) factorials)))
9
+ (define factorials (cons-stream 1 (mul-streams (stream-cdr integers) factorials)))
10
10
11
11
(module+ test
12
12
(require rackunit)
13
13
14
14
(test-case "Test for mul-stream "
15
15
(define s1 (list-to-stream '(2 3 4 5 )))
16
16
(define s2 (list-to-stream '(3 4 5 6 )))
17
- (define s3 (mul-stream s1 s2))
17
+ (define s3 (mul-streams s1 s2))
18
18
(check-equal? (stream-ref s3 2 ) 20 )
19
19
(check-equal? (stream-to-list s3 4 ) '(6 12 20 30 ))
20
20
)
Original file line number Diff line number Diff line change
1
+ #lang racket
2
+ (require "stream.rkt " )
3
+ (require "infinite-stream.rkt " )
4
+
5
+ (define (partial-sums s1)
6
+ (cons-stream (stream-car s1) (add-streams (partial-sums s1) (stream-cdr s1)))
7
+ )
8
+
9
+ (module+ test
10
+ (require rackunit)
11
+
12
+ (test-case "Test for partial-sums "
13
+ (define s1 (partial-sums integers))
14
+ (check-equal? (stream-to-list s1 5 ) '(1 3 6 10 15 ))
15
+ )
16
+ )
You can’t perform that action at this time.
0 commit comments