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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,77bf8fb943650b32 X-Google-Attributes: gid103376,public From: johnherro@aol.com Subject: Re: type declaration problem(beginner) Date: 1997/03/02 Message-ID: <19970302214000.QAA14807@ladder02.news.aol.com>#1/1 X-Deja-AN: 222593329 References: <1997Feb26.120011.27@whisky> X-Admin: news@aol.com Organization: AOL http://www.aol.com Newsgroups: comp.lang.ada Date: 1997-03-02T00:00:00+00:00 List-Id: Idawkins@whisky.nrl.navy.mil writes: > I have a type declarations, example: > type Month is (Jan, Feb, etc...) > I want to write another declaration for a array of > boolean values, Set_type. Use the type Month > for the indices into the array. type Set_Type is array(Month) of Boolean; Then you could declare, for example, Null_Set : constant Set_Type(others => false); or Short_Months : Set_Type := Set_Type'(Feb|Apr|Jun|Sep|Nov => True, others => False); The second example is written the way it is because it's always a good idea to qualify the aggregate when "others" follows named notation. This was more important in Ada 83 than it is in Ada 95, but it's still a good idea. The "Set_Type'" before the "(" is called qualifying the aggregate. When you have two objects that are one-dimensional arrays of Boolean, such as Set_Type, you can "and" and "or" the entire arrays. You don't have to set up a loop and "and" or "or" one element at a time. "And" corresponds to set intersection, and "or" is set union. Thus, A, B, C : Set_Type; ... A := B or C; sets A to B union C. At the Web and FTP sites below my signature, you can download my shareware Ada Tutor program, and there's a coupon there for a good Ada textbook; you send the coupon directly to the publisher. I hope this helps. - John Herro Software Innovations Technology http://members.aol.com/AdaTutor ftp://members.aol.com/AdaTutor