Re: How difficult is ada to learn?
- From: Matthew Heaney <mheaney@xxxxxxx>
- Date: Thu, 30 Jun 2005 10:34:59 -0400
Gene wrote:
Most people who start with Borland Pascal miss the built-in set and string data types. Ada gets the same effects with packages, but the syntax is far less elegant and readable.
I haven't done any Pascal in a while, so I don't remember the syntax for set manipulation, but Ada 2005 will have a set container type. It's an abstract data type, declared in a package in the normal way. It supports union, intersection, etc.
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:
type Integer_Array is array (Positive range <>) of Integer;
function "+" (IA : Integer) return Integer_Sets.Set is
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); begin ...;
That's not that inelegant. Not much different from Pascal, as I recall... .
- Follow-Ups:
- Re: How difficult is ada to learn?
- From: Randy Brukardt
- Re: How difficult is ada to learn?
- From: Gene
- Re: How difficult is ada to learn?
- From: Duncan Sands
- Re: How difficult is ada to learn?
- References:
- How difficult is ada to learn?
- From: Sm704
- Re: How difficult is ada to learn?
- From: Gene
- How difficult is ada to learn?
- Prev by Date: Re: How difficult is ada to learn?
- Next by Date: Re: How difficult is ada to learn?
- Previous by thread: Re: How difficult is ada to learn?
- Next by thread: Re: How difficult is ada to learn?
- Index(es):
Relevant Pages
|