3 (define (merge-weighted p1 p2 weightfn)
4 (cond ((stream-null? p1) p2)
7 (let ((p1car (stream-car p1))
8 (p2car (stream-car p2)))
9 (let ((w1 (weightfn (car p1car) (car (cdr p1car))))
10 (w2 (weightfn (car p2car) (car (cdr p2car)))))
13 (merge-weighted (stream-cdr p1) p2 weightfn)))
16 (merge-weighted p1 (stream-cdr p2) weightfn)))
20 (merge-weighted (stream-cdr p1)
25 (define (weighted-pairs s t weightfn)
27 (list (stream-car s) (stream-car t))
29 (stream-map (lambda (x) (list (stream-car s) x))
31 (weighted-pairs (stream-cdr s) (stream-cdr t) weightfn)
36 > (display-stream (weighted-pairs integers integers (lambda (i j) (+ i j))))
111 (display-stream (stream-filter (lambda (p)
114 (not (or (divides? 2 i)
120 (weighted-pairs integers integers (lambda (i j) (+ (* 2 i) (* 3 j) (* 5 i j))))))