Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Help needed for ada package
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 48 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Marc A. Criley  
View profile  
 More options Jul 25 2005, 1:45 pm
Newsgroups: comp.lang.ada
From: "Marc A. Criley" <mcNOS...@mckae.com>
Date: Mon, 25 Jul 2005 12:45:04 -0500
Local: Mon, Jul 25 2005 1:45 pm
Subject: Re: Help needed for ada package

strictly...@hotmail.com wrote:
> To anyone interested,

> I very urgently need this ada 95 package written for me and I am
> willing to pay anyone for their time. Here is the specification;

> The is supposed to be a basic database to monitor a group of made up
> citizens and their badness rating.

> Again, if anyone is interested I'm willing to pay for your services.

How much are homework assignments going for nowadays?  :-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Clubley  
View profile  
 More options Jul 25 2005, 1:47 pm
Newsgroups: comp.lang.ada
From: clubley@remove_me.eisner.decus.org-Earth .UFP (Simon Clubley)
Date: 25 Jul 2005 12:47:25 -0500
Local: Mon, Jul 25 2005 1:47 pm
Subject: Re: Help needed for ada package

In article <1122305318.728942.304...@f14g2000cwb.googlegroups.com>, strictly...@hotmail.com writes:
> To anyone interested,

> I very urgently need this ada 95 package written for me and I am
> willing to pay anyone for their time. Here is the specification;

> The is supposed to be a basic database to monitor a group of made up
> citizens and their badness rating.

[snip]

At least you didn't ask someone to design a weapons system for you. :-)

I am trying to decide if this is a troll or a homework assignment.

Assuming that it's the latter, paying someone to do your homework for
you is only a short term solution. Part of doing homework is learning
_how_ to solve problems.

When people want help with homework, they usually ask a very specific
question, along with posting the code that they have tried to date.

If you are stuck on the problem as a whole, can't your tutor give you
some guidance on getting started ?

Sorry that I can't be more help, but we've all faced these problems
while learning, and learning how to overcome them is a required part of
the learning process.

Simon.

--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP      
Microsoft: The Standard Oil Company of the 21st century


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Georg Bauhaus  
View profile  
 More options Jul 25 2005, 2:21 pm
Newsgroups: comp.lang.ada
From: Georg Bauhaus <bauh...@futureapps.de>
Date: Mon, 25 Jul 2005 20:21:27 +0200
Local: Mon, Jul 25 2005 2:21 pm
Subject: Re: Help needed for ada package

Simon Clubley wrote:
> In article <1122305318.728942.304...@f14g2000cwb.googlegroups.com>, strictly...@hotmail.com writes:
>>The is supposed to be a basic database to monitor a group of made up
>>citizens and their badness rating.
> At least you didn't ask someone to design a weapons system for you. :-)

> I am trying to decide if this is a troll or a homework assignment.

I'm trying to figure out what badness is, here. Or a bad citizen.
So far I have learned that in English, "He's bad!" can be a statement
approving of someone's favorable qualities. OTOH, the political
pendulum is currently swinging to the watchers side, so we might
be witnessing another large scale surveillance project.

Could someone do me a favor and elucidate?

TIA,
Georg


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frank J. Lhota  
View profile  
 More options Jul 25 2005, 2:46 pm
Newsgroups: comp.lang.ada
From: "Frank J. Lhota" <NOSPAM.lh...@adarose.com>
Date: Mon, 25 Jul 2005 18:46:51 GMT
Local: Mon, Jul 25 2005 2:46 pm
Subject: Re: Help needed for ada package
When you're done, I want to run this program to measure the badness of
Michael Jackson.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tmo...@acm.org  
View profile  
 More options Jul 25 2005, 3:26 pm
Newsgroups: comp.lang.ada
From: tmo...@acm.org
Date: Mon, 25 Jul 2005 14:26:06 -0500
Local: Mon, Jul 25 2005 3:26 pm
Subject: Re: Help needed for ada package
How many groups might a given citizen belong too?  With 10**6 citizens,
there are potentially 2**(10**6) subgroups (subtract 10**6 if loners
are not considered groups).

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ludovic Brenta  
View profile  
 More options Jul 25 2005, 6:12 pm
Newsgroups: comp.lang.ada
From: Ludovic Brenta <ludovic.bre...@tiscali.be>
Date: Tue, 26 Jul 2005 00:12:04 +0200
Local: Mon, Jul 25 2005 6:12 pm
Subject: Re: Help needed for ada package

strictly...@hotmail.com writes:
> I very urgently need this ada 95 package written for me and I am
> willing to pay anyone for their time. Here is the specification;
[...]
> Rate is supposed to enter a citizen with his/her ID (integer) and their
> badness (integer) into the database.
[...]
> There will be no more than 1 million citizens entered. Updates should
> be optimised at the expense of queries. Do not worry too much about
> error handling.

> The program is supposed to be compiled on gnat. I require both the code
> and a compiled file.

> Again, if anyone is interested I'm willing to pay for your services.

I don't think this is homework; I think it's worse than that.  Some
unknown group of unknown people are asking us to write a database
containing actual person records in it.  We don't know what country
the database will run in, what people will have their records in it,
what is the definition of "badness", and, most importantly, we don't
even know what this unknown group of people is planning to do with the
"bad" people.

"strictly_mk", who are you anyway?  If you don't have the time to
learn Ada, that's fine and fair but could you please elaborate on the
more important questions I raised?

--
Ludovic Brenta.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeffrey Carter  
View profile  
 More options Jul 25 2005, 7:33 pm
Newsgroups: comp.lang.ada
From: Jeffrey Carter <s...@spam.com>
Date: Mon, 25 Jul 2005 16:33:46 -0700
Local: Mon, Jul 25 2005 7:33 pm
Subject: Re: Help needed for ada package

strictly...@hotmail.com wrote:

> I very urgently need this ada 95 package written for me and I am
> willing to pay anyone for their time. Here is the specification;

Sounds good. I could do it for only $20 million, cash, in new $100 bills.

  spam.vcf
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tmo...@acm.org  
View profile  
 More options Jul 25 2005, 8:47 pm
Newsgroups: comp.lang.ada
From: tmo...@acm.org
Date: Mon, 25 Jul 2005 19:47:01 -0500
Local: Mon, Jul 25 2005 8:47 pm
Subject: Re: Help needed for ada package
>Potentially, it is possible an individual is associated with everyone
>else hence there being one group of one million or 999999 pairs of groups.

  "Group" is misleading here.  Your "procedure Associate" leads to a
symmetric boolean N x N matrix where M(I,J) is True iff person I and
person J have ever been associated.  Finding the worst citizen in the same
"group" as citizen X means finding everyone X knows, then for each of X's
associates, finding all their associates, for each of those finding all
their associates, etc etc, and noting the worst person you come across.
If this is a brand new police database, then there are probably very few
known associations, so that's not too terrible in either storage or time.
  If you've been monitoring all associations between any two people over
the last many years, everybody is "associated" with several hundred
others, each of whom is associated with several hundred, and so forth.
Evemtually you'll find that, as in "six degrees of Kevin Bacon",
everyone except for a few cloistered nuns is associated with Kevin Bacon,
and thus with each other, so there are only two groups - those citizens
"associated" with Kevin Bacon and those in the nunnery.  Assuming there's
someone more dangerous than the nuns, Next_Member will simply be an
enumeration of all non-nuns.  Is that useful?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve  
View profile  
 More options Jul 25 2005, 11:17 pm
Newsgroups: comp.lang.ada
From: "Steve" <nospam_steve...@comcast.net>
Date: Mon, 25 Jul 2005 20:17:50 -0700
Local: Mon, Jul 25 2005 11:17 pm
Subject: Re: Help needed for ada package

<strictly...@hotmail.com> wrote in message

news:1122305318.728942.304120@f14g2000cwb.googlegroups.com...

Sorry I don't have enough time to write the whole thing write now, but
here's a start (maybe someone else will step in to fill in another routine):

with Ada.Unchecked_Deallocation;
package body POP is

  type
  RO0O is record  lll1 : ID;  ll1l : Rating; end record; type
  ROO0 is array( positive range <> ) of
  RO0O; type R0OO is access all ROO0;

  procedure RO00 is new Ada.Unchecked_Deallocation( ROO0, R0OO );

  R00O : R0OO;  R0O0 : Natural := 0;

   procedure Associate (Citizen_1, Citizen_2 : in ID) is
   begin
      null;
   end Associate;

   function More_In_Group return Boolean is
   begin
      return More_In_Group;
   end More_In_Group;

   function Most_Dangerous return ID is
   begin
      return Most_Dangerous;
   end Most_Dangerous;

   function Next_Member return ID is
   begin
      return Next_Member;
   end Next_Member;

   procedure Rate
     (Citizen : in ID; Badness : in Rating)  is  begin
    if R0O0 = 0 then R00O := new ROO0( 1 .. 100 ); end if;
    if R0O0 + 1 > R00O.all'length then
    declare R000 : R0OO; begin R000 := new
    ROO0( 1 .. R0O0 + 100 ); R000.all( 1 .. R0O0 ) :=
    R00O.all( 1 .. R0O0 ); RO00( R00O ); R00O :=
    R000; end; end if; R0O0 := R0O0 + 1;
    R00O( R0O0 ).lll1 := citizen; R00O( R0O0 ).ll1l := badness; end
    Rate;

   procedure  reset is
   begin
      null;
   end reset;

end POP;

Steve
(The Duck)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Obry  
View profile  
 More options Jul 26 2005, 1:29 pm
Newsgroups: comp.lang.ada
From: Pascal Obry <pas...@obry.net>
Date: 26 Jul 2005 19:29:34 +0200
Local: Tues, Jul 26 2005 1:29 pm
Subject: Re: Help needed for ada package

Jeffrey Carter <s...@spam.com> writes:
> Sounds good. I could do it for only $20 million, cash, in new $100 bills.

And me for only $15 million :)

Pascal.

--

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tmo...@acm.org  
View profile  
 More options Jul 26 2005, 1:31 pm
Newsgroups: comp.lang.ada
From: tmo...@acm.org
Date: Tue, 26 Jul 2005 12:31:39 -0500
Local: Tues, Jul 26 2005 1:31 pm
Subject: Re: Help needed for ada package
  If you are a humanities major just trying to pass a required science
course, and just want something to barely "get by", forget priority queues
and databases and just use arrays.  If there aren't many citizens that
will work fine in both speed and storage.  If type ID is (<>); is for
instance "range 1 ..  100" just declare your arrays with ID as their
subscripts.  If ID is too big (eg, Integer), you can have a separate
lookup list to translate between ID and a (small) subscript value.
Even the "find all the associates of all the associates of ... of all
the associates of X can be done with a simple recursion and a check-off
list of citizens already looked at.
  In general, sitting back and asking "what information is required here?"
is a better start than "which of these complicated tools that I don't
really understand all that well, should I use?".  OTOH, be aware that more
than one dot-com company started with a simple implementation cooked up in
a dorm room that turned out not to scale up.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeffrey Carter  
View profile  
 More options Jul 26 2005, 6:20 pm
Newsgroups: comp.lang.ada
From: Jeffrey Carter <s...@spam.com>
Date: Tue, 26 Jul 2005 15:20:13 -0700
Local: Tues, Jul 26 2005 6:20 pm
Subject: Re: Help needed for ada package

Pascal Obry wrote:

> And me for only $15 million :)

Great, bidding war. Don't listen to Pascal, he won't deliver the quality
you'll get from me.

OK, $14.9 million, but that's my final offer.

  spam.vcf
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ed Falis  
View profile  
 More options Jul 26 2005, 3:03 pm
Newsgroups: comp.lang.ada
From: "Ed Falis" <fa...@verizon.net>
Date: Tue, 26 Jul 2005 19:03:57 GMT
Local: Tues, Jul 26 2005 3:03 pm
Subject: Re: Help needed for ada package

On Tue, 26 Jul 2005 13:29:34 -0400, Pascal Obry <pas...@obry.net> wrote:
> And me for only $15 million :)

Euros?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Obry  
View profile  
 More options Jul 26 2005, 3:05 pm
Newsgroups: comp.lang.ada
From: Pascal Obry <pas...@obry.net>
Date: 26 Jul 2005 21:05:52 +0200
Local: Tues, Jul 26 2005 3:05 pm
Subject: Re: Help needed for ada package

"Ed Falis" <fa...@verizon.net> writes:
> On Tue, 26 Jul 2005 13:29:34 -0400, Pascal Obry <pas...@obry.net> wrote:

> > And me for only $15 million :)

> Euros?

No $15 million is fine, but I'm ok for 15 million euros of course :)

Pascal.

--

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Georg Bauhaus  
View profile  
 More options Jul 27 2005, 5:07 am
Newsgroups: comp.lang.ada
From: Georg Bauhaus <bauh...@futureapps.de>
Date: Wed, 27 Jul 2005 11:07:36 +0200
Local: Wed, Jul 27 2005 5:07 am
Subject: Re: Help needed for ada package

Jeffrey Carter wrote:
> Pascal Obry wrote:

>> And me for only $15 million :)

> Great, bidding war. Don't listen to Pascal, he won't deliver the quality
> you'll get from me.

> OK, $14.9 million, but that's my final offer.

It's cheaper to buy in Europe,

http://www.ecb.int/stats/exchange/eurofxref/html/eurofxref-graph-usd....


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Krischik  
View profile  
 More options Jul 27 2005, 1:13 pm
Newsgroups: comp.lang.ada
From: Martin Krischik <krisc...@users.sourceforge.net>
Date: Wed, 27 Jul 2005 19:13:41 +0200
Local: Wed, Jul 27 2005 1:13 pm
Subject: Re: Help needed for ada package

strictly...@hotmail.com wrote:
>         type Society_Ptr is access all Society;

>         Pointer : Society_Ptr;

Are you sure you need a pointer.  Most Ada compilers won't have a problem
creating the even a large array in static memory:

http://en.wikibooks.org/wiki/Programming:Ada:Types:array

Do you really need "access all"

http://en.wikibooks.org/wiki/Programming:Ada:Types:access#Access_vs._...

And last not least: there is no "new" to be seen anywhere:

http://en.wikibooks.org/wiki/Programming:Ada:Types:access#Creating_ob...

Martin

--
mailto://krisc...@users.sourceforge.net
Ada programming at: http://ada.krischik.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Wright  
View profile  
 More options Jul 27 2005, 2:03 pm
Newsgroups: comp.lang.ada
From: Simon Wright <si...@pushface.org>
Date: Wed, 27 Jul 2005 19:03:41 +0100
Local: Wed, Jul 27 2005 2:03 pm
Subject: Re: Help needed for ada package
You could make Individual.Associate a packed array (1 .. 1_000_000) of
Boolean, set True if there's an Association .. though since
Association is symmetric as far as I can tell it might be better to
have a separate two-dimensional array for this.

I take it that ID is range 1 .. 1_000_000? if so you should index
Society by ID.

Why do you have pointers? you could just have an array of individuals.

Names are very important. "Pointer" is a very unhelpful name for the
concept you have in mind!

  type Individuals is array (ID) of Indivuals;
  Society : Individuals;

How are you going to know whether a given Individual exists? (has been
Rated, I think?)

--S


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeffrey Carter  
View profile  
 More options Jul 27 2005, 8:58 pm
Newsgroups: comp.lang.ada
From: Jeffrey Carter <s...@spam.com>
Date: Thu, 28 Jul 2005 00:58:35 GMT
Local: Wed, Jul 27 2005 8:58 pm
Subject: Re: Help needed for ada package

Simon Wright wrote:
> You could make Individual.Associate a packed array (1 .. 1_000_000) of
> Boolean, set True if there's an Association .. though since
> Association is symmetric as far as I can tell it might be better to
> have a separate two-dimensional array for this.

I'd probably use PragmARC.Skip_List_Unbounded for the collection of
rated innocent victims (appox O(log N) for insertion and lookup), each
having a list of associates. Then finding the highest rated is O(1), and
visiting each of her associates would be approx O(log N).

--
Jeff Carter
"Why don't you bore a hole in yourself and let the sap run out?"
Horse Feathers
49


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tmo...@acm.org  
View profile  
 More options Jul 27 2005, 9:53 pm
Newsgroups: comp.lang.ada
From: tmo...@acm.org
Date: Wed, 27 Jul 2005 20:53:19 -0500
Local: Wed, Jul 27 2005 9:53 pm
Subject: Re: Help needed for ada package
> visiting each of her associates would be approx O(log N).

  And visiting all the associates of each of those ...
IIRC Warshall's algorithm for transitive closure is O(n**3).
Is there a faster way?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve  
View profile  
 More options Jul 27 2005, 10:27 pm
Newsgroups: comp.lang.ada
From: "Steve" <nospam_steve...@comcast.net>
Date: Wed, 27 Jul 2005 19:27:45 -0700
Local: Wed, Jul 27 2005 10:27 pm
Subject: Re: Help needed for ada package
<strictly...@hotmail.com> wrote in message

news:1122475184.849564.159870@g44g2000cwa.googlegroups.com...

> With the code kindly posted by Steve and with the advice some of you
> here gave me I have attempted this thing again and this is the code I
> have 'written'/'modified'. I've simplified it somewhat since I am
> supposed to show the concept of the procedures and functions working
> regardless if they fail after a certain amount of time.

Now that you're asking for help, and not for someone to do it for you, as
you can see, you get a lot more positive response.

If the array is going to be fixed in size, why not just use:

  type Society is array( 1 .. 1000000 ) of Individual;

  Society_Buffer : Society;

  In my original response I used a pointer because I dynamically allocated
an array to store individuals.  When the array became full, I dynamically
allocated a new larger array, copied the values from the original array to
the new larger array and then deallocated the original array.  It is
certainly simpler to just go with a fixed maximum size.

> procedure Rate (Citizen : in ID; Badness : in Rating) is
> begin
> Counter := Counter + 1;
> Pointer( Counter ).Person := Citizen;
> Pointer( Counter ).Rating := Badness;
> Pointer( Counter ).Associate := null;
> Pointer( Counter ).Reported := false;
> end;
> end Rate;

  Just a note: One of the features I really like about Ada is the ability to
do record assignments, so this Rate function could be:

  Counter := Counter + 1;
  Pointer( Counter ) := ( Person => Citizen, Rating => Badness, Associate =>
null, Reported => False );

One way to handle the "associates" is to create an association code for each
individual.  When two citizens are associated, make the id's of the
associates the same.

You might, for example start out with an association id of 0 indicating no
association.  When the Associate procedure is called, find the location of
each of the citizens and handle each of the cases:
  If both associates have no association, create a new association id, and
assign it to both.
  If just one of the associates has a non-zero association id, assign it to
the other.
  If both of the associates have a non-zero association id (ie: A and B),
then change the association ID of all citizens that are currently B to A.

I am assuming that:
  if A associated with B and B associated with C it is implied that A
associated with C.

I hope this helps,
Steve
(The Duck)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeffrey Carter  
View profile  
 More options Jul 28 2005, 12:21 pm
Newsgroups: comp.lang.ada
From: Jeffrey Carter <s...@spam.com>
Date: Thu, 28 Jul 2005 09:21:09 -0700
Local: Thurs, Jul 28 2005 12:21 pm
Subject: Re: Help needed for ada package

tmo...@acm.org wrote:

>   And visiting all the associates of each of those ...
> IIRC Warshall's algorithm for transitive closure is O(n**3).
> Is there a faster way?

I thought the requirement was only to visit all the associates of the
highest rated individual. If you have to visit associates of associates
of associates of ... then it becomes a little more time intensive.

--
Jeffrey Carter
"Now go away or I shall taunt you a second time."
Monty Python and the Holy Grail
E-mail: jeffrey_r_carter-nr [commercial-at]
         raytheon [period | full stop] com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ludovic Brenta  
View profile  
 More options Jul 28 2005, 2:33 pm
Newsgroups: comp.lang.ada
From: Ludovic Brenta <ludovic.bre...@tiscali.be>
Date: Thu, 28 Jul 2005 20:33:32 +0200
Local: Thurs, Jul 28 2005 2:33 pm
Subject: Re: Help needed for ada package
Whoa, everyone seems to be going over the top, I think the solution
can be much simpler.

generic
    type ID is (<>); --some discrete type to be put here
package POP is
   --update database
  type Rating is new Integer range 0..255;
  procedure Rate (Citizen : in ID;
                  Badness : in Rating);
  procedure Associate (Citizen_1, Citizen_2 : in ID);
  --query the database
  function Most_Dangerous return ID;
  function Next_Member return ID;
  function More_In_Group return Boolean;
  --administrative
  procedure reset;
end POP;

Since the type ID is discrete, why not just use that as the array index type?

package body POP is
   Society : array (ID) of Rating := (others => Rating'First);
   Associacion : array (ID, ID) of Boolean := (others => others => False));
   pragma Pack (Association);

   Last_Reported : ID := ID'First;

   procedure Rate (Citizen : in ID;
                   Badness : in Rating) is
   begin
      Society (Citizen) := Rating;
   end Rate;

   procedure Associate (Citizen_1, Citizen_2 : in ID) is
   begin
      Association (Citizen_1, Citizen_2) := True;
   end Associate;

   function Most_Dagerous return ID is
      Result : ID := ID'First;
   begin
      for J in Society'Range loop
         if Society (J) > Result then
            Result := J;
         end if;
      end loop;
      return Result;
   end Most_Dangerous;

   function Next_Member return ID is
      J : constant ID := Most_Dangerous;
   begin
      if Last_Reported = ID'First then
         Last_Reported := J;
      end if;
      for K in ID'Succ (Last_Reported) .. Association'Last (2) loop
         if Association (J, K) then
            Last_Reported := K;
            exit;
         end loop;
      end loop;
      return Last_Reported;
   end Next_Member;

   function More_In_Group return Boolean is    
      J : constant ID := Most_Dangerous;
      Result : Boolean := False;
   begin
      for K in ID'Succ (Last_Reported) .. Association'Last (2) loop
         if Association (J, K) then
            Result := True;
            exit;
         end loop;
      end loop;
      return Result;
   end More_In_Group;

   procedure Reset is
   begin
      Society := (others => Rating'First);
      Association := (others => others => False));
      Last_Reported := ID'First;
   end Reset;
end POP;

Of course, the above solution is outrageously inefficient, both
memory- and CPU-wise.  Optimisations are left as an exercise to the
reader.

--
Ludovic Brenta.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tmo...@acm.org  
View profile  
 More options Jul 28 2005, 3:51 pm
Newsgroups: comp.lang.ada
From: tmo...@acm.org
Date: Thu, 28 Jul 2005 14:51:43 -0500
Local: Thurs, Jul 28 2005 3:51 pm
Subject: Re: Help needed for ada package
Nice and clean but:

Most_Dangerous = 10
Last_Reported = 20
Citizens 5 and 6 are associated.
then re-rate Citizen 5 as even more dangerous than 10.
Citizen 6 will not be noticed by Next_Member or More_In_Group.

Associate as written is not symmetric - is that what's wanted?

association is not transitive - is that what's wanted?

I would also change type Rating to Rating_Levels and array Society to
Rating.  Then "if Rating(J) > " reads better than "if Society(J) > ".

I notice a couple of typos, but the compiler will point them out.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve  
View profile  
 More options Jul 28 2005, 9:57 pm
Newsgroups: comp.lang.ada
From: "Steve" <nospam_steve...@comcast.net>
Date: Thu, 28 Jul 2005 18:57:48 -0700
Local: Thurs, Jul 28 2005 9:57 pm
Subject: Re: Help needed for ada package
<strictly...@hotmail.com> wrote in message

news:1122547648.069514.63520@g14g2000cwa.googlegroups.com...
> Thank you for all the suggestions. Here is what I've done so far,
[snip]

> What I wanna ask is how can you reset an entire array? For
> More_In_Group I want to reset the Members_Array and use a similar loop
> used in Next_Member to rebuild it, this way the previous member looked
> up disappears and all I would need to do is check if there are elements
> still in the array to return true or false. Any suggestions?

In your original post you indiciated:
  "The procedure rest resets the database to its original state."

So, I think all you need to do is set your counts and indexes back to 0.

Steve
(The Duck)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tmo...@acm.org  
View profile  
 More options Jul 29 2005, 4:37 am
Newsgroups: comp.lang.ada
From: tmo...@acm.org
Date: Fri, 29 Jul 2005 03:37:15 -0500
Local: Fri, Jul 29 2005 4:37 am
Subject: Re: Help needed for ada package

>   type Association_Matrix is array (Id'First .. Id'Last) of
>Association_Vector;
>   pragma Pack(Association_Matrix);
>   --   1_000_000 rows of 125_000 bytes is 125_000_000_000 bytes
>   --   very fat, 125GB

  Remember that a symmetric array A(1 .. N, 1 .. N) can be stored in half
the space as a vector V(1 .. (N*(N+1))/2), where A(i,j) is at
V((max(i,j)*(max(i,j)-1))/2+min(i,j))

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 48   Newer >
« Back to Discussions « Newer topic     Older topic »