From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,14da4c08f1736a33 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!a37g2000yqi.googlegroups.com!not-for-mail From: Phil Clayton Newsgroups: comp.lang.ada Subject: Re: Array initialization in SPARK Date: Sat, 30 Oct 2010 06:11:41 -0700 (PDT) Organization: http://groups.google.com Message-ID: <18dee21a-a23b-4bd7-a85b-ee359811e710@a37g2000yqi.googlegroups.com> References: <03b3b80e-9313-45b8-939a-7dde7780288c@y23g2000yqd.googlegroups.com> <3c36d3ba-6748-4aa9-9304-a219b11415bb@30g2000yql.googlegroups.com> <20101028182601.058336d9@senier-offen> <0570b344-ba2b-4de5-9c5a-a71d61c73bfd@l20g2000yqm.googlegroups.com> NNTP-Posting-Host: 91.110.248.6 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1288444301 31676 127.0.0.1 (30 Oct 2010 13:11:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 30 Oct 2010 13:11:41 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a37g2000yqi.googlegroups.com; posting-host=91.110.248.6; posting-account=v7gx3AoAAABfjb9m5b7l_Lt2KVEgQBIe User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.15) Gecko/2009102704 Fedora/3.0.15-1.fc10 Firefox/3.0.15,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:14972 Date: 2010-10-30T06:11:41-07:00 List-Id: On Oct 30, 9:10=A0am, AdaMagica wrote: > On 30 Okt., 03:04, Phil Clayton wrote: > > > ... =A0We > > could then write something like: > > > =A0 Out_Matrix :=3D > > =A0 =A0 =A0Matrix'(for I in Natural range Out_Matrix'Range(1) =3D> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(for J in Natural range Out_Matrix'Range= (2) =3D> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 In_Matrix(J, I))); > > But we would need an assertion that 'Range(1) equals 'Range(2), else > we would get Constraint_Error. (Equal lengths would not suffice - no > sliding there.) Yes, you would need Out_Matrix'Range(1) =3D In_Matrix'Range(2) and vice- versa. I actually meant to write: Out_Matrix :=3D Matrix'(for I in Natural range In_Matrix'Range(2) =3D> (for J in Natural range In_Matrix'Range(1) =3D> In_Matrix(J, I))); which still requires the same assertions. However, this r.h.s. could be used as the return value of a Matrix_Transpose function which would enable us to avoid such assertions because we don't have to specify the unconstrained array size independently, e.g. Out_Matrix : Matrix :=3D Matrix_Transpose(In_Matrix); I suppose this is a more 'functional' style of Ada... Phil