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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e511f3ccb3da24af X-Google-Attributes: gid103376,public From: mjsilva@my-deja.com Subject: Re: How to make like Fortran "do i = 1,20,2" Date: 2000/07/27 Message-ID: <8lq8ps$6ln$1@nnrp1.deja.com>#1/1 X-Deja-AN: 651561749 References: <8lpcbe$40n$1@news.uit.no> <39805669.3E7CF6CF@lmtas.lmco.com> X-Http-Proxy: 1.1 x68.deja.com:80 (Squid/1.1.22) for client 206.169.137.75 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Jul 27 21:15:45 2000 GMT X-MyDeja-Info: XMYDJUIDmjsilva Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) Date: 2000-07-27T00:00:00+00:00 List-Id: I'd say that it's the required looping conditions that are somewhat convoluted. Acting only on every Nth element is much, much less common than acting on every element (I honestly can't remember the last time I needed to do this), so perhaps more explicit coding for this case is not only acceptable but even desirable. Mike In article <39805669.3E7CF6CF@lmtas.lmco.com>, Gary Scott wrote: > Hmmm, these and similar examples posted do not make Ada look very > elegant...it makes a very simple concept seem somewhat convoluted. > > Larry Kilgallen wrote: > > > > In article <8lpcbe$40n$1@news.uit.no>, reinert@ola.npolar.no (Reinert Korsnes) writes: > > > > > > Hi, > > > > > > How can one in Ada elegantly make a loop through each 2 element of an array ? > > > I am looking for something like: "do i = 1,20,2" in Fortran, or > > > > > > for I in A'range ("step 2") loop > > > something... > > > end loop; > > > > =========== > > > > for I in A'range loop > > if (I - A'first) mod 2 = 0 > > then > > null; > > end if; > > end loop; > > > > But of course that does nothing to ensure that A'length is an even number. > > > > =========== > > > > for I2 in A'first/2 .. A'last/2 loop > > declare > > I : INTEGER := I2*2; > > begin > > null; > > end; > > end loop; > > > > That approach will have problems if either A'length is an odd > > number or if either limit of A'range is an odd number. > > > > =========== > > > > But what does Fortran do in those negative and odd number cases ? > Sent via Deja.com http://www.deja.com/ Before you buy.