comp.lang.ada
 help / color / mirror / Atom feed
* "for E of Vector1 loop" equivalent  to "for n in Vector1.First_Index ..  Vector1.Last_Index loop ?
@ 2016-09-19  7:23 reinkor
  2016-09-19  7:37 ` Stephen Leake
  0 siblings, 1 reply; 5+ messages in thread
From: reinkor @ 2016-09-19  7:23 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-19  8:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19  7:23 "for E of Vector1 loop" equivalent to "for n in Vector1.First_Index .. Vector1.Last_Index loop ? reinkor
2016-09-19  7:37 ` Stephen Leake
2016-09-19  7:50   ` reinkor
2016-09-19  8:02     ` Egil H H
2016-09-19  8:41       ` reinkor

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