--- /dev/null
+#lang planet neil/sicp
+
+;; stream-of-numbers -> floating point number -> number
+(define (stream-limit s limit)
+ (let ([num0 (stream-car s)]
+ [num1 (stream-car (stream-cdr s))])
+ (let ([diff (- num0 num1)])
+ (if (< (abs diff) limit)
+ num1
+ (stream-limit (stream-cdr s) limit)))))
\ No newline at end of file
--- /dev/null
+#lang racket
+
+(define (ln2-summands n)
+ (cons-stream (/ 1.0 n)
+ (stream-map - (ln2-summands (+ n 1)))))
+
+(define ln2 (partial-sums (ln2-summands 1)))
\ No newline at end of file
--- /dev/null
+#lang racket
+
+#|
+
+Writing down the pairs, one can sort of form the following judgement.
+
+For any particular pair of the form S0Tm, the number of terms which precedes it
+is (+ (* 2 (- m 1)) 1) for m >= 2
+
+For a pair of the form S1Tm, it is (* (- m 1) 4) for m >= 2.
+
+Similarly one can get working formulae for other row, column pairs.
+
+|#
\ No newline at end of file
--- /dev/null
+#lang racket
+
+(define (interleave s1 s2)
+ (if (stream-null? s1)
+ s2
+ (cons-stream (stream-car s1)
+ (interleave s2 (stream-cdr s1)))))
+
+(define (pairs s t)
+ (cons-stream
+ (list (stream-car s) (stream-car t))
+ (interleave (interleave
+ (stream-map (lambda (x) (list (stream-car s) x))
+ (stream-cdr t))
+ (stream-map (lambda (y) (list y (stream-car t)))
+ (stream-cdr s)))
+ (pairs (stream-cdr s) (stream-cdr t)))))
+
+
+
+
+
--- /dev/null
+#lang racket
+
+#|
+
+'interleave' is a procedure and not a special form because of which the arguments
+of the interleave will be evaluated before interleave itself is called. This will
+result in an infinite number of calls to 'pair'.
+
+|#
\ No newline at end of file
--- /dev/null
+#lang racket
+
+(define (triples s t u)
+ (cons-stream (append (stream-car (pairs s t))
+ (list (stream-car u)))
+ (interleave
+ (stream-map (lambda(p) (append p (list (stream-car u))))
+ (stream-cdr (pairs s t)))
+ (triples (stream-cdr s)
+ (stream-cdr t)
+ (stream-cdr u)))))
\ No newline at end of file