ivanjovanovic / sicp

Structure and Interpretation of Computer Programs study notes with exercise solutions
375 stars 69 forks source link

Could you format the codes in "Message passing" part in "2.4/notes.md" please ? #1

Closed zakilo closed 9 years ago

zakilo commented 9 years ago

It's hard to read for me. Many thanks !

k1ngpr4wn commented 9 years ago

I've created a pull-request, but try this patch:

--- a/2.4/notes.md
+++ b/2.4/notes.md
@@ -57,16 +57,15 @@ The other way of solving the problem of generic operations that need to
 be done is so called `message passing`. It is hard to explain it without
 the example. So here is one simple example

-(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 -- MAKE-FROM-REAL-IMAG" op))))
-  dispatch)
+    (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 -- MAKE-FROM-REAL-IMAG" op))))
+        dispatch)
zakilo commented 9 years ago

nice & thanks !