Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,34 @@
#include "share/atspre_staload.hats"
%{^
#include <math.h>
%}
extern fn sqrt : double -<> double = "mac#sqrt"
fun
iterate {n : nat}
(phi : double,
n : int n) : @(double, intGte 1) =
let
val phi1 = 1.0 + (1.0 / phi)
and n1 = succ n
in
if abs (phi1 - phi) <= 1.0e-5 then
@(phi1, n1)
else
iterate {n + 1} (phi1, n1)
end
implement
main0 () =
let
val @(phi, n) = iterate {0} (1.0, 0)
val _ = $extfcall (int, "printf",
"Result: %.10f after %d iterations\n",
phi, n)
val _ = $extfcall (int, "printf",
"The error is approximately %.10f\n",
phi - (0.5 * (1.0 + sqrt (5.0))))
in
end