From 8905f914a0a2174f4984564dd857d49ada87cda4 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com>
Date: Mon, 20 Sep 2010 22:20:40 +0530
Subject: [PATCH] code in the messaging passing section

---
 src/sicp/ch2_4.rkt | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/sicp/ch2_4.rkt b/src/sicp/ch2_4.rkt
index ed348fd..4f14ab5 100644
--- a/src/sicp/ch2_4.rkt
+++ b/src/sicp/ch2_4.rkt
@@ -103,4 +103,16 @@
 (define (make-from-mag-ang r a)
   (make-from-mag-ang-polar r a))
 
-;;; data directed programming
+;;; message passing
+(define (make-from-real-imag x y)
+  (define (dispatch op)
+    (cond
+      [(eq? op 'real-part) x]
+      [(eq? op 'imag-part) y]
+      [(eq? op 'magnitude)
+       (sqrt (+ (square x) (square y)))]
+      [(eq? op 'angle) (atan y x)]
+      [else 
+       (error "unknown op" op)]))
+  dispatch)
+
-- 
2.45.2