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: a07f3367d7,7ef7640503406872 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!b1g2000yql.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: I need feedback Date: Thu, 16 Jun 2011 00:34:55 -0700 (PDT) Organization: http://groups.google.com Message-ID: <60103dcd-f9a9-4577-8367-2cbd1747c23e@b1g2000yql.googlegroups.com> References: <87aadk5bgd.fsf@ludovic-brenta.org> <04cf1b2d-5ae4-4219-9d4c-20231ca47375@k16g2000yqm.googlegroups.com> <7249477f-1b33-4546-b1cd-f7333e2cff00@y30g2000yqb.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1308209695 12765 127.0.0.1 (16 Jun 2011 07:34:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 16 Jun 2011 07:34:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b1g2000yql.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012111 Red Hat/3.0.6-1.el5 Firefox/3.0.6,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19867 Date: 2011-06-16T00:34:55-07:00 List-Id: juanmiuk wrote: > Well, Thank you for all suggestion, I think I follow all of them. > There you go the final version: > > with Ada.Text_IO; > with Ada.Integer_Text_IO; > with Ada.Numerics.Discrete_Random; > with Ada.Strings.Fixed; > > use Ada; > use Ada.Strings.Fixed; > > procedure Sort_3_Numbers is > > =A0 =A0 =A0 =A0 subtype One_Ten is Integer range 1 .. 10; > > =A0 =A0 =A0 =A0 package Roulette10 is new Ada.Numerics.Discrete_Random(On= e_Ten); > > =A0 =A0 =A0 =A0 Gen10: Roulette10.Generator; > > =A0 =A0WIDTH_NUM : constant One_Ten :=3D One_Ten'Width; > =A0 =A0THE_BASE =A0: constant One_Ten :=3D 10; This is not necessary, see why below. > =A0 =A0procedure Output_Num > =A0 =A0 =A0 ( The_Number : in =A0 =A0 One_Ten; > =A0 =A0 =A0 =A0 Width_Num =A0: in =A0 =A0 One_Ten; > =A0 =A0 =A0 =A0 The_Base =A0 : in =A0 =A0 One_Ten ) > =A0 =A0is > > =A0 =A0begin > > =A0 =A0 =A0 Integer_Text_IO.Put(The_Number, Width_Num, The_Base); > > =A0 =A0end Output_Num; This entire procedure does nothing but call Integer_Text_IO.Put, so is not necessary; you might as well call Integer_Text_IO.Put directly. In the spec of Integer_Text_IO.Put, the parameter Base has a default value of 10, so you need not specify it. You could even do away with Width_Num like this: package One_Ten_IO is new Ada.Text_IO.Integer_IO (Num =3D> One_Ten); This would initialize the constant One_Ten_IO.Default_Width to be One_Ten'Width; you would not have to do it yourself. > begin > =A0 =A0Roulette10.Reset(Gen10); > =A0 =A0for I in One_Ten'Range loop > =A0 =A0 =A0 Main_Process : declare > =A0 =A0 =A0 =A0 =A0A =A0 =A0 =A0 =A0 =A0 =A0 =A0 : One_Ten :=3D Roulette1= 0.Random(Gen10); > =A0 =A0 =A0 =A0 =A0B =A0 =A0 =A0 =A0 =A0 =A0 =A0 : One_Ten :=3D Roulette1= 0.Random(Gen10); > =A0 =A0 =A0 =A0 =A0C =A0 =A0 =A0 =A0 =A0 =A0 =A0 : One_Ten :=3D Roulette1= 0.Random(Gen10); > > =A0 =A0 =A0 =A0 =A0First =A0 : One_Ten; > =A0 =A0 =A0 =A0 =A0Secon =A0 : One_Ten; > =A0 =A0 =A0 =A0 =A0Third =A0 : One_Ten; > =A0 =A0 =A0 begin > =A0 =A0 =A0 =A0 =A0Output_Num(A, WIDTH_NUM, THE_BASE); > =A0 =A0 =A0 =A0 =A0-- Changing all the Output_Num by Integer_Text_IO.Put(= A, WIDTH_NUM, THE_BASE) > =A0 =A0 =A0 =A0 =A0-- as Jeffrey Carter comments then won't be any duppli= cations. Or, even more succinctly: One_Ten_IO.Put (A); [rest snipped]. Hope this helps. -- Ludovic Brenta.