comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: array slices
Date: Tue, 13 May 2003 01:49:19 GMT
Date: 2003-05-13T01:49:19+00:00	[thread overview]
Message-ID: <zaYva.820040$3D1.463310@sccrnsc01> (raw)
In-Reply-To: 3EC0494F.A7D67AA4@bellsouth.net

> a : array(1..4) of integer;
> c : array( 1..2, 1..4 ) of integer;
>   a(1..4) := c(1)(1..4);
There are two problems here.  1) you can only take slices of one
dimensional arrays (yes, that is annoying).  2) A and C are of different
(anonymous) types so the compiler will point that out if you try to assign
a chunk of one to the other.
  If you do
type Rows is array(1 .. 4) of integer;
a : Rows;
c : array(1 .. 2) of Rows;
then any of
 a(1 .. 4) := c(1)(1 .. 4);
 a := c(1);
 a(3 .. 4) := c(2)(1 .. 2);
are ok.

or
type Rows is array(integer range <>) of integer;
a : Rows(1 .. 4);
c : array(1 .. 2) of Rows(1 .. 4);
d : array(5 .. 6) of Rows(11 .. 25);
a(1 .. 2) := d(6)(11 .. 12);
will also work.



  parent reply	other threads:[~2003-05-13  1:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-13  1:24 array slices gshibona @ b e l l s o u t h . n e t
2003-05-13  1:28 ` Jeffrey Carter
2003-05-13  1:49 ` tmoran [this message]
2003-05-13 11:53 ` James S. Rogers
replies disabled

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