From 87f19316259fa5c6787e6183527649fa2beacbb1 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Wed, 24 Nov 2010 17:43:03 +0530
Subject: [PATCH] solutions to 2.38 and 2.39.

---
 src/sicp/ex2_38.rkt | 11 +++++++++++
 src/sicp/ex2_39.rkt | 14 ++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 src/sicp/ex2_38.rkt
 create mode 100644 src/sicp/ex2_39.rkt

diff --git a/src/sicp/ex2_38.rkt b/src/sicp/ex2_38.rkt
new file mode 100644
index 0000000..446f7ff
--- /dev/null
+++ b/src/sicp/ex2_38.rkt
@@ -0,0 +1,11 @@
+#lang racket
+
+(define (fold-left op initial coll)
+  (define (iter result rest)
+    (if (null? rest)
+        result
+        (iter (op result (car rest))
+              (cdr rest))))
+  (iter initial coll))
+
+(provide fold-left)
\ No newline at end of file
diff --git a/src/sicp/ex2_39.rkt b/src/sicp/ex2_39.rkt
new file mode 100644
index 0000000..712baa0
--- /dev/null
+++ b/src/sicp/ex2_39.rkt
@@ -0,0 +1,14 @@
+#lang racket
+
+(require "utils.rkt"
+         "ex2_36.rkt"
+         "ex2_38.rkt")
+
+(define fold-right accumulate)
+
+(define (reverse1 coll)
+  (fold-right (lambda (x y) (append y (list x))) '() coll))
+
+(define (reverse2 coll)
+  (fold-left (lambda (x y) (cons y x)) '() coll))
+  
-- 
2.45.2