From 3451888d61bf357043ea479ff83901efb2828217 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Sat, 9 Jul 2011 21:56:12 +0530
Subject: [PATCH] solutions to 3.58 and 3.59

---
 src/sicp/ex3_58.rkt | 13 +++++++++++++
 src/sicp/ex3_59.rkt | 21 +++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 src/sicp/ex3_58.rkt
 create mode 100644 src/sicp/ex3_59.rkt

diff --git a/src/sicp/ex3_58.rkt b/src/sicp/ex3_58.rkt
new file mode 100644
index 0000000..d0258fb
--- /dev/null
+++ b/src/sicp/ex3_58.rkt
@@ -0,0 +1,13 @@
+#lang racket
+
+(define (expand num den radix)
+  (cons-stream
+   (quotient (* num radix) den)
+   (expand (remainder (* num radix) den) den radix)))
+
+#|
+
+The function gives the digits in the fractional part of the division as a
+stream.
+
+|#
\ No newline at end of file
diff --git a/src/sicp/ex3_59.rkt b/src/sicp/ex3_59.rkt
new file mode 100644
index 0000000..2f80ee8
--- /dev/null
+++ b/src/sicp/ex3_59.rkt
@@ -0,0 +1,21 @@
+#lang racket
+
+;; part a
+(define (integrate-series stream)
+  (define (integrate-iter S I)
+    (stream-map (lambda (s i)
+                  (* s (/ 1 i)))
+                S
+                I))
+  (integrate-iter stream
+                  (integers-starting-from 1)))
+
+;; part b
+(define sine-series
+  (cons-stream 0 (integrate-series cosine-series)))
+
+(define cosine-series
+    (cons-stream 1 (scale-stream (integrate-series sine-series) -1)))
+
+
+
-- 
2.45.2