blob: 28f0a1de19b9135d9a93a216322f7e6cbbe8a41b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
"square" (x): float -> float
{
return x *f x;
}
"integr"(f, low, high, n): int -> float -> float -> int -> float
{
var h, x, s, i;
h = (high -f low) /f floatofint n;
x = low;
s = 0.0;
i = n;
{{ loop {
if (! (i > 0)) exit;
s = s +f (f(x): float -> float);
x = x +f h;
i = i - 1;
} }}
return s *f h;
}
"test"(n) : int -> float
{
return "integr"("square", 0.0, 1.0, n): int -> float -> float -> int -> float;
}
|