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,1e40bdb19094c551 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.202.168 with SMTP id kj8mr13721552pbc.1.1333556422970; Wed, 04 Apr 2012 09:20:22 -0700 (PDT) Path: r9ni18152pbh.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Array/Matrix Help Date: Wed, 4 Apr 2012 09:20:22 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4668787.390.1333556422640.JavaMail.geo-discussion-forums@ynib40> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1333556422 30497 127.0.0.1 (4 Apr 2012 16:20:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 4 Apr 2012 16:20:22 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-04-04T09:20:22-07:00 List-Id: On Tuesday, April 3, 2012 7:55:26 PM UTC-7, Will wrote: > I need to create function Create_Matrix that accepts four > Int_Arrays. It must determine if all 4 Int_Arrays are of equal length > and then creates and returns an Int_Matrix of the 2 or more arrays > with equal length. >=20 > Here is what I am thinking so far, I believe it will work but seems > inefficient and I am looking for efficiency in my coding. I am not > sure how to determine which ones are equal other than a bunch of if/ > elsif statement that cover every possible combination of them being > equal then write the code that will create the matrix for that given > combination of arrays. Any ideas on something better than the > following. I am assuming that there will not be 2 sets of arrays that > are equal (i.e. 2 arrays of length 5 , and another 2 of length 7) > There would only be 1 common length. >=20 > function Create_Matrix (A, B, C, D : Int_Array) return Int_Matrix >=20 > begin >=20 > if A'Length =3D B'Length and A'Length =3D C'Length and A'Lengt= h > =3D D'Length then >=20 > Then continue to do this all the way until I cover every combination > of 2 or more arrays that are equal length and then whichever if > statement it satisfies create the Int_Matrix by each array being its > own line inside the matrix. >=20 > Can anyone offer help or ideas. Any hints/help is greatly > appreciated... I prefer that over just giving me the code. I don't think there's a good way to do this except with a bunch of if/then/= elses. If you're super-concerned about efficiency, you might want to creat= e a 6-bit integer where each bit corresponds to one of the six pairs of com= parisons (add 1 if A'Length=3DB'Length, add 2 if A'Length=3DC'Length, add 4= if something...) and then do a CASE on the integer to cover all 64 possibi= lities. But that's an ugly way to write this just to eliminate a few nanos= econds. -- Adam