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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,994623ba34b222de X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!s31g2000vbp.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Egil_H=F8vik?= Newsgroups: comp.lang.ada Subject: Re: Ada code snippet help (array of arrays) Date: Thu, 14 May 2009 01:05:12 -0700 (PDT) Organization: http://groups.google.com Message-ID: <5628eb43-3d56-4b20-976a-6bb0f40dcd49@s31g2000vbp.googlegroups.com> References: NNTP-Posting-Host: 193.71.180.107 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1242288312 13894 127.0.0.1 (14 May 2009 08:05:12 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 14 May 2009 08:05:12 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s31g2000vbp.googlegroups.com; posting-host=193.71.180.107; posting-account=P68zsgoAAABKpXKMUuwuUZ_RfBk1kZfB User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5838 Date: 2009-05-14T01:05:12-07:00 List-Id: On May 13, 4:11=A0pm, Vamp4L wrote: > Trying to figure out why my code doesn't work > This line in particular doesn't compile "if Theater(Seat)(reserved) =3D > F then" : > > with Ada.Text_Io; use Ada.Text_Io; > procedure Ch4Ex22 is > =A0 =A0package Int_Io is new Integer_Io(Integer); > =A0 =A0use Int_Io; > =A0 =A0package Boolean_Io is new Enumeration_Io(Boolean); > =A0 =A0use Boolean_Io; > > =A0 =A0T: constant Boolean :=3D True; > =A0 =A0F: constant Boolean :=3D False; No need to define your own constants... True and False are already enumerated values (constants) of type Boolean. > =A0 =A0type Seatattributes is (Reserved, Balcony); > =A0 =A0type SeatType is array(SeatAttributes) of Boolean; Attributes of a type are usually represented as a record: type Seating is record Reserved : Boolean; Balcony : Boolean; end record; > =A0 =A0type Theater is array (1..50) of SeatType; > =A0 =A0A: Theater :=3D (1=3D>(T,F),2..7=3D>(F,F),8=3D>(T,F),9..15=3D>(F,F= ),16=3D> > (T,F), > =A0 =A0 =A0 17..23=3D>(F,F),24=3D>(T,F),25..29=3D>(F,F),30..31=3D>(F,T),3= 2=3D>(T,T), > 33..49=3D>(F,T),50=3D>(T,T)); > How about: A : Theater :=3D ( 1 | 8 | 16 | 24 =3D> (Reserved =3D> True, Balcony =3D> False), 2..7 | 9..15 | 17..23 | 25..29 =3D> (Reserved =3D> False, Balcony =3D> False), 30..31 | 33..49 =3D> (Reserved =3D> False, Balcony =3D> True), 32 | 50 =3D> (Reserved =3D> True, Balcony =3D> True )); > =A0 =A0begin > > =A0 =A0 =A0 for Seat in Theater'range loop > =A0 =A0 =A0 =A0 =A0if Theater(Seat)(reserved) =3D F then > =A0 =A0 =A0 =A0 =A0 =A0 Put(Seat, 1); New_Line; > =A0 =A0 =A0 =A0 =A0end if; > =A0 =A0 =A0 end loop; > > end Ch4Ex22;