comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Terminating a task
Date: 14 Jul 2003 16:45:32 -0700
Date: 2003-07-14T23:45:32+00:00	[thread overview]
Message-ID: <1ec946d1.0307141545.2175a770@posting.google.com> (raw)
In-Reply-To: ubs4hv4eaar8hbmr2vut59ananvsuvra9a@4ax.com

Craig Carey <research@ijs.co.nz> wrote in message news:<ubs4hv4eaar8hbmr2vut59ananvsuvra9a@4ax.com>...
> 
> PS. The new "Computer Language Shootout" website now has Ada. 
> 
>    http://dada.perl.it/shootout/index.html
> 
> My "wc" word count program got eliminated probably since the tester
> could not link in Win32 "_setmode" and "_read". (Ada 95 packages do not
> allow accurate reading from the standard input). 


Your word count program got eliminated because it is junk.

I have no idea what you mean about not being able to accurately read
from standard input.

Here is a simplified version of the program, which closely follows the
gcc example:


with Ada.Text_IO;            use Ada.Text_IO;
with Ada.Characters.Latin_1; use Ada.Characters;
with Ada.Integer_Text_IO;    use Ada.Integer_Text_IO;

procedure WC is

   Line  : String (1 .. 133);
   Last  : Natural;
   
   NL, NW, NC : Integer'Base := 0;
   
   Word : Boolean := False;

begin

   while not End_Of_File loop
   
      Get_Line (Line, Last);
      
      NC := NC + Last;
            
      for I in Line'First .. Last loop
         if Line (I) = Latin_1.Space or Line (I) = Latin_1.HT then
            Word := False;
            
         elsif not Word then
            Word := True;
            NW := NW + 1;
            
         end if;
      end loop;
      
      if Last < Line'Last then
         Word := False;
         NL := NL + 1;
      end if;
      
   end loop;    
   
   Put ("NL="); Put (NL, Width => 0); New_Line;
   Put ("NW="); Put (NW, Width => 0); New_Line;
   Put ("NC="); Put (NC, Width => 0); New_Line;
   
end WC;

-Matt



  reply	other threads:[~2003-07-14 23:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-12 14:03 Terminating a task kat-Zygfryd
2003-07-12 14:37 ` kat-Zygfryd
2003-07-14  9:34   ` Craig Carey
2003-07-14 23:45     ` Matthew Heaney [this message]
2003-07-15 17:49       ` Craig Carey
2003-07-15 18:30         ` David C. Hoos
2003-07-16  5:26         ` Matthew Heaney
2003-07-15 22:37       ` Robert I. Eachus
2003-07-16  5:00         ` Matthew Heaney
2003-07-16 18:19           ` Robert I. Eachus
replies disabled

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