From: Kilgallen@eisner.decus.org.nospam (Larry Kilgallen)
Subject: Re: How to make like Fortran "do i = 1,20,2"
Date: 2000/07/27
Date: 2000-07-27T00:00:00+00:00 [thread overview]
Message-ID: <T47$ewqox+R8@eisner.decus.org> (raw)
In-Reply-To: 8lpcbe$40n$1@news.uit.no
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 ?
next prev parent reply other threads:[~2000-07-27 0:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-27 0:00 How to make like Fortran "do i = 1,20,2" Reinert Korsnes
2000-07-27 0:00 ` G. de Montmollin
2000-07-27 0:00 ` Lutz Donnerhacke
2000-07-27 0:00 ` Larry Kilgallen [this message]
2000-07-27 0:00 ` Gary Scott
2000-07-27 0:00 ` Larry Kilgallen
2000-07-27 0:00 ` Pat Rogers
2000-07-27 0:00 ` mjsilva
2000-07-27 0:00 ` Matthew J Heaney
2000-07-28 0:00 ` Gary Scott
2000-07-28 0:00 ` mjsilva
2000-07-29 0:00 ` Ehud Lamm
2000-07-28 0:00 ` Richard Riehle
2000-07-29 0:00 ` Robert I. Eachus
[not found] ` <39833637.3B83BFAC@lmtas.lmco.com>
2000-07-29 0:00 ` Gary Scott
2000-07-27 0:00 ` des walker
2000-07-27 0:00 ` tmoran
2000-07-28 0:00 ` Reinert Korsnes
2000-07-28 0:00 ` Gautier
2000-07-29 0:00 ` tmoran
2000-07-27 0:00 ` Gary Scott
2000-07-27 0:00 ` Ken Garlington
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox