text
stringlengths
0
234
-- function Sub(x, y: in Integer) return Integer is (X-Y);
-- function Mul(x, y: in Integer) return Integer is ((X * Y + 8192 / 2) / 8192);
-- function Div(x, y: in Integer) return Integer is ((X * 8192 + y / 2) / Y);
-- function OfInt(x: in Integer) return Integer is (X * 8192);
function Add(x, y: in Integer) return Integer is
begin
return X+Y;
end Add;
function Sub(x, y: in Integer) return Integer is
begin
return X-Y;
end Sub;
function Mul(x, y: in Integer) return Integer is
T : Integer := X * Y;
begin
return (t + 8192 / 2) / 8192;
end Mul;
function Div(x, y: in Integer) return Integer is
T : Integer := X * 8192;
begin
return (t + y / 2) / y;
end Div;
function OfInt(x: in Integer) return Integer is
begin
return X * 8192;
end OfInt;
function iter(N, A, B, Xn, Yn: in Integer) return Boolean is
xn2, Yn2 : Integer;
begin
if n = 100 then return true; end if;
xn2 := mul(xn, xn);
yn2 := mul(yn, yn);
if add(xn2, yn2) > ofint(4) then return false; end if;
return iter(n+1, a, b, add(sub(xn2, yn2), a),
add(mul(ofint(2), mul(xn, yn)), b));
Function Definition: procedure Pascal is
Function Body: type Node;
type List is access Node;
type Node is record
Value: Integer;
Next: List;
end record;
function Get(L: List; I: Integer) return Integer is
begin
if I = 0 then return L.Value; end if;
return Get(L.next, I - 1);
Function Definition: procedure Fact is
Function Body: procedure PrintInt(N: Integer) is
C: Integer := N rem 10;
begin
if N > 9 then PrintInt(N / 10); end if;
Put(Character'Val(48 + C));
Function Definition: procedure Test is
Function Body: type R is record A, B: Integer; end record;
procedure P1(X, Y: in out R) is
begin
X.A := 0;
X.B := 1;
Y.A := 2;
Y.B := 3;
if X.A = Y.A and X.B = Y.B then Put('a'); end if;
X := Y;
if X.A = Y.A and X.B = Y.B then Put('d'); end if;
Function Definition: procedure Test_a is
Function Body: procedure R(N: Integer) is
begin
if N = 0 then return; end if;
Put('a');
R(N - 1);
Function Definition: procedure Test is
Function Body: function F return character is
begin return 'a';
end F;
function G(C: Character) return character is
begin return c;
end G;
begin
Put(F); New_Line;
Put(G('b')); New_Line;
Put(G(F)); New_Line;
Function Definition: procedure BST is
Function Body: type Node;
type BST is access Node;
type Node is record
Value: Integer;
Left, Right: BST;
end record;
-- insertion utilisant le passage par référence
procedure Add(X: Integer; B: in out BST) is
begin