rest of section 1.3
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Thu, 27 May 2010 12:46:25 +0000 (18:16 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Thu, 27 May 2010 12:46:25 +0000 (18:16 +0530)
src/sicp/ch1_3.clj

index 5aaf159db314c146bdf1e862fb278a5a787acc45..355cdc416f5f978cffac121376fcda5606a01054 100644 (file)
 
 (defn newton-sqrt [x]
   (newton-method (fn [y] (- (square y) x))
-                1.0))
\ No newline at end of file
+                1.0))
+
+(defn fixed-point-of-transform [g transform guess]
+  (fixed-point (transform g) guess))
+
+(defn sqrt1 [x]
+  (fixed-point-of-transform (fn [y] (/ x y))
+                           average-damp
+                           1.0))
+
+(defn sqrt2 [x]
+  (fixed-point-of-transform (fn [y] (- (square y) x))
+                           newton-transform
+                           1.0))
\ No newline at end of file