Re: How difficult is ada to learn?



"Matthew Heaney" <mheaney@xxxxxxx> wrote in message
news:42c40313$0$32193$39cecf19@xxxxxxxxxxxxxxxxxxxxx
Matt Heaney wrote:

> If not having "built-in" syntax is a hardship, then you can always
> define array-based set operations yourself. For example, suppose we
> have a set whose element type is Integer, then we can do this:

The following example seems pretty confused.

> type Integer_Array is array (Positive range <>) of Integer;
>
> function "+" (IA : Integer) return Integer_Sets.Set is

What's the definition of "Integer_Sets.Set"? Shouldn't IA have type
Integer_Array, rather than Integer?

> S : Set;
> begin
> for Indx in IA'Range loop
> S.Include (IA (Indx));
> end loop;
>
> return S;
> end;
>
> Now you can say:
>
> declare
> S1 : Set := +(1, 2, 3);
> S2 : Set := +(2, 3, 4);
> S3 : Set := S1 or S2;
> S4 : Set := S3 and +(1, 3);
> S5 : Set := +(42, 43) or +(44, 45);

Presuming that Integer_Sets.Set has "or" and "and" operations.

Randy.



.



Relevant Pages