From: Ramakrishnan Muthukrishnan Date: Thu, 27 May 2010 12:46:25 +0000 (+0530) Subject: rest of section 1.3 X-Git-Url: https://git.rkrishnan.org/uri/frontends/FTP-and-SFTP.rst?a=commitdiff_plain;h=4f3e9a388f8b28963b177f2e914acf897f2a012e;p=sicp.git rest of section 1.3 --- diff --git a/src/sicp/ch1_3.clj b/src/sicp/ch1_3.clj index 5aaf159..355cdc4 100644 --- a/src/sicp/ch1_3.clj +++ b/src/sicp/ch1_3.clj @@ -129,4 +129,17 @@ (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