comp.lang.ada
 help / color / mirror / Atom feed
From: mjsilva@my-deja.com
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: <8lq8ps$6ln$1@nnrp1.deja.com> (raw)
In-Reply-To: 39805669.3E7CF6CF@lmtas.lmco.com

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 <Gary.L.Scott@lmtas.lmco.com> 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.




  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 ` Ken Garlington
2000-07-27  0:00 ` des walker
2000-07-27  0:00   ` Gary Scott
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 ` Larry Kilgallen
2000-07-27  0:00   ` Gary Scott
2000-07-27  0:00     ` Pat Rogers
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     ` mjsilva [this message]
2000-07-27  0:00     ` Larry Kilgallen
2000-07-27  0:00 ` Lutz Donnerhacke
2000-07-27  0:00 ` G. de Montmollin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox