From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,587e0e0a16d65b10 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.karotte.org!news2.arglkargh.de!noris.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 27 Feb 2009 12:30:25 +0100 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.19 (Macintosh/20081209) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Invade wikipedia! References: <49a6d506$0$32680$9b4e6d93@newsspool2.arcor-online.net> <4a18f335-30f6-4216-8376-0310eb560445@p11g2000yqe.googlegroups.com> In-Reply-To: <4a18f335-30f6-4216-8376-0310eb560445@p11g2000yqe.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <49a7ced2$0$31342$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 27 Feb 2009 12:30:26 CET NNTP-Posting-Host: 325c0d9c.newsspool4.arcor-online.net X-Trace: DXC=VC95iO>@5IQFm0Y?OE@2^X4IUK Adam Beneschan schrieb: > On Feb 26, 9:44 am, Georg Bauhaus > wrote: >> Ivan Levashew schrieb: >> >>> Integer_Text_IO.Put (8); >> Integer should not be used in the first place, >> and neither in examples ... (What do you mean by >> Huh? :-) > > Hmmm... This thread started out with a request that we increase the > visibility of Ada by providing examples for some Wikipedia algorithms > written in Ada. What better way to get people interested in the > language than by making it seem that you have to define your own > numeric types before you can write any code? :) :( :-| Adding the declarations of suitable number types in an example algorithm maybe doesn't seem to hurt that much. Taking http://en.wikipedia.org/wiki/Insertion_sort as an example, I tried type Mug is (Metal, Plastic, Thermo, Porcelain); type Mug_Number is range 1 .. 10; type Mug_List is array(Mug_Number) of Mug; procedure Insertion_Sort(A: in out Mug_List) is j: Mug_Number'Base; value: Mug; begin for i in A'First + 1 .. A'Last loop value := A(i); j := i-1; while j >= A'First and then A(j) > value loop A(j+1) := A(j); j := j-1; end loop; A(j+1) := value; end loop; end Insertion_Sort; No big changes due to going from Pseudo-Pascal to real Ada, I think, other than having to explain 'Base. The "and then" of the shifting loop actually clarifies that short circuit control is required. If the Wikipedia example authors could agree on an example problem space (like Mugs in this case), then even the three declaractions before Insertion_Sort could be left out. Instead, a simple with will do, or as custom seems to permit, visibility of the problem space declarations is always assumed.