Wir benötigen zunächst ein Paket, das allgemeine Definitionen enthält.
package Defs is
Sodann instantiieren wir eine Standard-Menge mit dem Elementtyp Defs.real.
with General_Set, Standard_Boolean, Defs;
package Standard_Set is new General_Set(Defs.real,Standard_Boolean.stand_bool);
Die generische Funktion Closed_Interval gestattet uns, später Grund-Mengen zu instantiieren.
with Standard_Boolean;
generic
type real is digits
l,u: real;
function Closed_Interval(I: real)
return Standard_Boolean.stand_bool'CLASS;
function Closed_Interval(I: real)
return Standard_Boolean.stand_bool'CLASS
is
begin
if I
return Standard_Boolean.true_value;
else
return Standard_Boolean.false_value;
end if;
end Closed_Interval;
Solche Intervalle werden mit
with Closed_Interval, Defs;
function Interval_1 is new Closed_Interval(Defs.real,0.0,10.0);
with Closed_Interval, Defs;
function Interval_2 is new Closed_Interval(Defs.real,20.0,30.0);
with Defs, Closed_Interval, Standard_Boolean, Standard_Set, Interval_1, Interval_2;
use Standard_Boolean;
procedure main_stand
is
int_1_ptr: Standard_Set.Member_Function_Pointer := Interval_1'Access;
int_2_ptr: Standard_Set.Member_Function_Pointer := Interval_2'Access;
my_set_1, my_set_2, my_set_3: Standard_Set.set;
begin
my_set_1 :=
Standard_Set.Create(
Member_Function =
my_set_2 :=
Standard_Set.Create(
Member_Function =
my_set_3 := Standard_Set.Union(my_set_1, my_set_2);
if Standard_Set.Is_Member(5.0, my_set_3) = Standard_Boolean.true_value then
end if;
end main_stand;