Created
December 11, 2015 13:23
-
-
Save tetsu-miyagawa/f45b4d48ce617c2e1c43 to your computer and use it in GitHub Desktop.
CTMCP Section 3.2.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare Sqrt Iterate Abs | |
fun {Abs X} if X < 0.0 then ~X else X end end | |
fun {Iterate S IsDone Transform} | |
if {IsDone S} then S | |
else S1 in | |
S1={Transform S} | |
{Iterate S1 IsDone Transform} | |
end | |
end | |
fun {Sqrt X} | |
{Iterate | |
1.0 | |
fun {$ G} {Abs X-G*G}/X < 0.00001 end | |
fun {$ G} (G+X/G)/2.0 end} | |
end | |
{Browse {Sqrt 10.0}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment