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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7596cfba54ad3207,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-28 02:07:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!small.news.tele.dk!128.39.3.168!uninett.no!not-for-mail From: Reinert Korsnes Newsgroups: comp.lang.ada Subject: Trivial Ada question Date: Fri, 28 Jun 2002 11:07:18 +0200 Organization: UNINETT Message-ID: NNTP-Posting-Host: sthrkou.ffi.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: dolly.uninett.no 1025255414 24413 193.156.99.159 (28 Jun 2002 09:10:14 GMT) X-Complaints-To: news-abuse@uninett.no NNTP-Posting-Date: Fri, 28 Jun 2002 09:10:14 +0000 (UTC) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:26758 Date: 2002-06-28T11:07:18+02:00 List-Id: 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