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=-0.1 required=5.0 tests=AXB_XMAILER_MIMEOLE_OL_024C2, BAYES_00,MAILING_LIST_MULTI,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7596cfba54ad3207 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-28 04:32:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!212.43.194.69!fr.clara.net!heighliner.fr.clara.net!freenix!enst!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: Trivial Ada question Date: Fri, 28 Jun 2002 06:33:32 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1025263923 19897 137.194.161.2 (28 Jun 2002 11:32:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 28 Jun 2002 11:32:03 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: reinert.korsnes@chello.no Xref: archiver1.google.com comp.lang.ada:26763 Date: 2002-06-28T06:33:32-05:00 If N is not referenced within the loop you could do: for I in A'Range loop if not some condition (I) then N := N - 1; exit; end if; end loop; N := N + 1; ----- Original Message ----- From: "Reinert Korsnes" Newsgroups: comp.lang.ada To: Sent: June 28, 2002 5:57 AM Subject: Re: Trivial Ada question > Correction below. It always happens :-) > > reinert > > Reinert Korsnes wrote: > > > Yes, maybe the simplest possible. > > The example below is also somehow simple, > > but I hoped for some "exit name" solution > > which I have not yet noticed :-) > > > > reinert > > > > All_OK := 1; > > for I in A'Range loop > > if not some condition (I) then > > All_OK := 1; > > obs, I mean All_OK := 0; > > > exit; > > end if; > > end loop; > > N := N + All_OK; > > > > > > David C. Hoos, Sr. wrote: > > > >> How about > >> > >> All_OK : Boolean; > >> . > >> . > >> . > >> All_OK := True; > >> for I in A'Range loop > >> if not some condition (I) then > >> All_OK := False; > >> exit; > >> end if; > >> end loop; > >> if ALL_OK then > >> N := N + 1; > >> end if; > >> > >> ----- Original Message ----- > >> From: "Reinert Korsnes" > >> Newsgroups: comp.lang.ada > >> To: > >> Sent: June 28, 2002 4:07 AM > >> Subject: Trivial Ada question > >> > >> > >>> Hi, > >>> > >>> I would like to ask about a program construct: > >>> > >>> I want to test if some condition holds for all values > >>> of I in A'range and in this case the variable > >>> N should be incremented by one ( N := N + 1; ). > >>> How can I do this most elegant and effective with Ada95 > >>> (without "goto") ? > >>> Assume I do not want to make a separate subroutine for this. > >>> > >>> This example is simple but not computationally optimal (two tests): > >>> > >>> for I in A'range loop > >>> exit when "not some condition(I); > >>> if I = A'last then > >>> -- Everything OK to the end: > >>> N := N + 1; > >>> end if; > >>> end loop; > >>> > >>> This example is ugly but more computationally optimal (one test): > >>> > >>> for I in A'range loop > >>> if "not some condition(i)" then > >>> N := N - 1; > >>> exit; > >>> end if; > >>> end loop; > >>> N := N + 1; > >>> > >>> Tricks by "named loops" also seem ugly. > >>> > >>> reinert > >>> > >>> _______________________________________________ > >>> comp.lang.ada mailing list > >>> comp.lang.ada@ada.eu.org > >>> http://ada.eu.org/mailman/listinfo/comp.lang.ada > >>> > >>> > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada > >