From 84a9387597aac93c06f02990b8a68d5e93ae75c9 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Wed, 11 Aug 2010 20:27:43 +0530
Subject: [PATCH] solution to 2.41

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

diff --git a/src/sicp/ex2_41.clj b/src/sicp/ex2_41.clj
new file mode 100644
index 0000000..e43773a
--- /dev/null
+++ b/src/sicp/ex2_41.clj
@@ -0,0 +1,21 @@
+(ns sicp.ex2_41
+  (:use [sicp.ch2-2 :only (enumerate-interval accumulate append)]))
+
+(defn triplets [n]
+  (accumulate append
+              nil
+              (accumulate append
+                          nil
+                          (map (fn [i]
+                                 (map (fn [j]
+                                        (map (fn [k] (list i j k))
+                                             (enumerate-interval 1 (- j 1))))
+                                      (enumerate-interval 1 (- i 1))))
+                               (enumerate-interval 1 n)))))
+
+(defn sum-triplets [triplet]
+  (accumulate + 0 triplet))
+
+(defn ordered-triplets [n sum]
+  (filter #(= (sum-triplets %) sum)
+          (triplets n)))
\ No newline at end of file
-- 
2.45.2