Commit 9501813 1 parent 6ae400d commit 9501813 Copy full SHA for 9501813
File tree 1 file changed +5
-16
lines changed
1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -103,22 +103,11 @@ always guess that the square root of any number is 1
103
103
(sqrt-iter 1.0 x))
104
104
```
105
105
106
- If we type these definitions to the interpreter, we can use
107
- sqrt just as we can use any function:
108
-
109
- ```
110
- > (sqrt 9)
111
- 3.00009155413138
112
-
113
- > (sqrt (+ 100 37))
114
- 11.704699917758145
115
-
116
- > (sqrt (+ (sqrt 2) (sqrt 3)))
117
- 1.7739279023207892
118
-
119
- > (square (sqrt 1000))
120
- 1000.000369924366
121
- ```
106
+ Now, let's play with it:
107
+ <iframe frameborder="0" width="100%" height="800px"
108
+ src=
109
+ "http://app.klipse.tech?eval_only=1&cljs_in=(defn%20square%20%5Bx%5D%0A%20%20(* %20x%20x))%0A%0A(defn%20average%20%5Bx%20y%5D%0A%20%20(%2F%20(%2B%20x%20y)%202))%0A%0A(defn%20good-enough%3F%20%5Bguess%20x%5D%0A%20%20(%3C%20(abs%20(-%20(square%20guess)%20x))%200.001))%0A%0A(defn%20improve%20%5Bguess%20x%5D%0A%20%20(average%20guess%20(%2F%20x%20guess)))%0A%0A(defn%20abs%20%5Bn%5D%0A%20%20(max%20n%20(-%20n)))%0A%0A(defn%20sqrt-iter%20%5Bguess%20x%5D%0A%20%20(if%20(good-enough%3F%20guess%20x)%0A%20%20%20%20guess%0A%20%20%20%20(sqrt-iter%20(improve%20guess%20x)%20x)))%0A%0A(defn%20sqrt%20%5Bx%5D%0A%20%20(sqrt-iter%201.0%20x))%0A%0A%5B(sqrt%20100)%0A%20(sqrt%209)%0A%20(sqrt%20(%2B%20100%2037))%0A%20(sqrt%20(%2B%20(sqrt%202)%20(sqrt%203)))%0A%20(square%20(sqrt%201000))%5D">
110
+ </iframe >
122
111
123
112
The sqrt ` program ` also illustrates that the simple procedural
124
113
language we have introduced so far is sufficient for writing any
You can’t perform that action at this time.
0 commit comments