* Newbie Arrays
@ 1999-08-13 0:00 Ronald Ayoub
1999-08-14 0:00 ` Gautier
1999-08-14 0:00 ` Matthew Heaney
0 siblings, 2 replies; 3+ messages in thread
From: Ronald Ayoub @ 1999-08-13 0:00 UTC (permalink / raw)
Right now I'm learning about multidimensional arrays and arrays of arrays.
I want to do something similiar to this with multidimensional arrays:
for I in V'first..V'last loop
for J in V(I)'first..V(I)'last loop
V(I)(J) := I * J;
end loop;
end loop;
but I can't see how to use the 'first and 'last attributes with
multidimensional arrays. In C there is no real difference between
an array of arrays and a multidimensional arrays except syntactically.
Are array of arrays more commonly used by Ada programers.
Thanks.
Ron
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Newbie Arrays
1999-08-13 0:00 Newbie Arrays Ronald Ayoub
@ 1999-08-14 0:00 ` Gautier
1999-08-14 0:00 ` Matthew Heaney
1 sibling, 0 replies; 3+ messages in thread
From: Gautier @ 1999-08-14 0:00 UTC (permalink / raw)
To: Ronald Ayoub
(...)
> but I can't see how to use the 'first and 'last attributes with
> multidimensional arrays.
'first(1) 'first(2) etc.
--
Gautier
--------
http://members.xoom.com/gdemont/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Newbie Arrays
1999-08-13 0:00 Newbie Arrays Ronald Ayoub
1999-08-14 0:00 ` Gautier
@ 1999-08-14 0:00 ` Matthew Heaney
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Heaney @ 1999-08-14 0:00 UTC (permalink / raw)
In article <7p1555$bf0$1@dailyplanet.wam.umd.edu> , rayoub@wam.umd.edu
(Ronald Ayoub) wrote:
> Right now I'm learning about multidimensional arrays and arrays of arrays.
> I want to do something similiar to this with multidimensional arrays:
>
> for I in V'first..V'last loop
> for J in V(I)'first..V(I)'last loop
> V(I)(J) := I * J;
> end loop;
> end loop;
for I in V'Range (1) loop
for J in V'Range (2) loop
V (I) (J) := I * J;
end loop;
end loop;
> but I can't see how to use the 'first and 'last attributes with
> multidimensional arrays.
Like the 'Range attribute, the 'First and 'Last attributes take a parameter
specifying which dimension.
But never say
for I in V'First (1) .. V'Last (1) loop ...;
Instead, say
for I in V'Range (1) loop ...;
> In C there is no real difference between
> an array of arrays and a multidimensional arrays except syntactically.
Not quite. In C, there is no such thing as a multidimensional array. All
arrays are really arrays-of-arrays.
Read Expert C Programming, by Peter van der Linden, for a good discussion of
this.
> Are array of arrays more commonly used by Ada programers.
In Ada, we have both arrays-of-arrays, and true multidimensional arrays.
Which is used depends on the nature of the problem.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-08-14 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-13 0:00 Newbie Arrays Ronald Ayoub
1999-08-14 0:00 ` Gautier
1999-08-14 0:00 ` Matthew Heaney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox