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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9c8d43df5d883263 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-15 09:35:33 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!newsfeed.wirehub.nl!newsfeed.online.be!zur.uu.net!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: Two Dimensional Array X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3C6D4536.860B6EE5@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3c6cf3db.11214605@news.demon.co.uk> Mime-Version: 1.0 Date: Fri, 15 Feb 2002 17:28:22 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:20050 Date: 2002-02-15T17:28:22+00:00 List-Id: Brian A Crawford wrote: > > The code fragment shows the end result of my efforts so far. > My problem is associating the values 1 or 0 to each cell of the array. > By having the numbers 1 to 50 in numerical order the numbers 1 and 0 > are very haphazard placed and are difficult to define and update. > > If the array was firstly defined as say 1,21,34,50,17,4, etc, 48,16 > then the 1 and 0 are placed together in the array and are very easy to > associate quickly in groups of 5. > Example > Event := (1 => (1,1,1,1,1,0,0,0,0,0,1,1,1,1,1 etc > 21 => (0,0,0,0,0,1,1,1,1,1,0,0,0,0,0, etc > 34 => (0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, etc > and so on. > > This is a code fragment. > Number1 : Integer; > Number2 : Integer; > > subtype Firstevent is Integer range 1..50; > subtype Secondevent is Integer range 1..50; > type Two_Events_Type is array (Firstevent, Secondevent) of > Integer; > Event : Two_Events_Type; > > begin > --get input data > > Event := (0 => > (1,0,0,1,0,1,1,0,0,0,0,1,1,0,1,1,1,0,1,etc,0,1,0,1,1,1,0,0,1,1), > 1=>(1,1,0,1,0,0,1,0,0,1,1,1,etc > 2=> and so forth > > as you can see the 1's and 0's are all over the place. > How can I define subtypes FirstEvent and SecondEvent out of sequence? First, since zero is not a value of Firstevent, you may have problems with assigning this aggregate to Event. Second, since the components of Two_Events_Type can only have the values 0 and 1, it is probably a good idea to specify this: subtype Bit is Integer range 0 .. 1; type Two_Events_Type is array (Firstevent, Secondevent) of Bit; Third, since Event is a constant, it is probably a good idea to define it as such: Event : constant Two_Events_Type := (...); Fourth, you probably ought to review ARM 4.3.3 on named array aggregates and ARM 3.8.1 on discrete choices. You can't define an out of order numeric (sub)type, but you can order things any way you like in a named aggregate. So you can say Event : constant Two_Events_Type := (01 => (01 | 07 | 13 | ... => 0, others => 1), 02 => (...), ...); > > Secondly then can I make an abbreviation to the array referencing eg > if AN is the sequence of 5 x 1's at {3,4,5,6,7} and BN is is the > sequence of 5 x 1's at {17,18,19,20,21} position and similar for CN DN > EN etc how may I use that abbreviation in some way like this? > > Event := (0 => (AN, BN, others => 0), > 21 => (CN, others =>0), > 34 => (DN, AN, CN, others 0)) etc No, but a named aggregate has the same effect. -- Jeffrey Carter