From 5ec86bcda9141f7afb31cd9b329bcf78307b721a Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Sun, 20 Jun 2010 10:19:58 +0530
Subject: [PATCH] solution to 2.18

---
 src/sicp/ex2_18.clj | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 src/sicp/ex2_18.clj

diff --git a/src/sicp/ex2_18.clj b/src/sicp/ex2_18.clj
new file mode 100644
index 0000000..b56c4e8
--- /dev/null
+++ b/src/sicp/ex2_18.clj
@@ -0,0 +1,24 @@
+(ns sicp.ex2_18
+  (:use [clojure test]))
+
+(defn turn-around-1 [lst]
+  (reduce #(cons %2 %1) '() lst))
+
+
+(defn turn-around-2 [lst]
+  (let [reverse (fn [lst1 lst2]
+		  (if (empty? lst1)
+		    lst2
+		    (recur (rest lst1) (cons (first lst1) lst2))))]
+    (reverse lst '())))
+
+
+(deftest test-turn-around-1
+  (are [x y] [= x y]
+       (turn-around-1 (list 1 2 3 4)) (list 4 3 2 1)
+       (turn-around-1 (list 1 4 9 16 25)) (list 25 16 9 4 1)))
+
+(deftest test-turn-around-2
+  (are [x y] [= x y]
+       (turn-around-2 (list 1 2 3 4)) (list 4 3 2 1)
+       (turn-around-2 (list 1 4 9 16 25)) (list 25 16 9 4 1)))
-- 
2.45.2