comp.lang.ada
 help / color / mirror / Atom feed
From: reinkor <reinkor@gmail.com>
Subject: "for E of Vector1 loop" equivalent  to "for n in Vector1.First_Index ..  Vector1.Last_Index loop ?
Date: Mon, 19 Sep 2016 00:23:09 -0700 (PDT)
Date: 2016-09-19T00:23:09-07:00	[thread overview]
Message-ID: <23ee42b9-8145-4d15-a745-a264505be8ff@googlegroups.com> (raw)

Assume Vector1 is a vector (container) and I want to loop through it in the direction Vector1.First_Index .. Vector1.Last_Index.

Is the following equivalent:

for n in Vector1.First_Index .. Vector1-Last_Index loop
   <do domething with Vector1(n)>
end loop;

and 

for E of Vector1 loop
  <do something with E>
end loop;

?

It is for me not directly intuitive that the latter construct
process the vector elements in the same order as the former. 
I feel I should find the answer in the definition of Ada - but din not :-)

reinert


             reply	other threads:[~2016-09-19  7:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19  7:23 reinkor [this message]
2016-09-19  7:37 ` "for E of Vector1 loop" equivalent to "for n in Vector1.First_Index .. Vector1.Last_Index loop ? Stephen Leake
2016-09-19  7:50   ` reinkor
2016-09-19  8:02     ` Egil H H
2016-09-19  8:41       ` reinkor
replies disabled

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