comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <mheaney@on2.com>
Subject: Re: How difficult is ada to learn?
Date: Thu, 30 Jun 2005 10:34:59 -0400
Date: 2005-06-30T14:34:59+00:00	[thread overview]
Message-ID: <42c40313$0$32193$39cecf19@news.twtelecom.net> (raw)
In-Reply-To: <1120141150.107320.139080@f14g2000cwb.googlegroups.com>

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...



  reply	other threads:[~2005-06-30 14:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-30  0:44 How difficult is ada to learn? Sm704
2005-06-30  5:11 ` Ludovic Brenta
2005-06-30  6:15   ` Preben Randhol
2005-06-30 14:19 ` Gene
2005-06-30 14:34   ` Matthew Heaney [this message]
2005-06-30 15:00     ` Duncan Sands
2005-06-30 18:38     ` Gene
2005-06-30 19:32       ` Matthew Heaney
2005-06-30 18:59     ` Randy Brukardt
2005-06-30 19:36       ` Matthew Heaney
2005-06-30 15:01   ` Matthew Heaney
2005-06-30 22:35     ` Robert A Duff
2005-07-15  2:27       ` Waldek Hebisch
2005-07-15  5:14         ` Ludovic Brenta
2005-07-01  5:37     ` Jeffrey Carter
2005-06-30 16:43 ` Martin Krischik
2005-06-30 19:36 ` svaa
2005-06-30 22:53 ` chris
2005-06-30 22:54   ` chris
2005-07-01  5:39   ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox