From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Sat, 16 Oct 2010 19:40:54 +0000 (+0530)
Subject: solution to 2.33 in scheme
X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/%22doc.html/frontends/install-details.html?a=commitdiff_plain;h=f5a91ad7773bef2789b58549fe8ca7d75770b781;p=sicp.git

solution to 2.33 in scheme
---

diff --git a/src/sicp/ex2_33.rkt b/src/sicp/ex2_33.rkt
new file mode 100644
index 0000000..312ea07
--- /dev/null
+++ b/src/sicp/ex2_33.rkt
@@ -0,0 +1,24 @@
+#lang racket
+
+(require "utils.rkt")
+
+(define (map f coll)
+  (accumulate (lambda (x y) (cons (f x) y))
+              '()
+              coll))
+
+(map square '(1 2 3 4 5))
+
+(define (append seq1 seq2)
+  (accumulate cons
+              seq2
+              seq1))
+
+(append '(1 2 3) '(4 5 6))
+
+(define (length seq)
+  (accumulate (lambda (x y) (+ 1 y))
+              0
+              seq))
+
+(length '(1 2 3 4 5))
\ No newline at end of file