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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,74a56083ffbe573d,start X-Google-Attributes: gid103376,public From: Ken Garlington Subject: Zoo question Date: 1996/08/12 Message-ID: <320F16B6.6944@lmtas.lmco.com>#1/1 X-Deja-AN: 173734076 content-type: text/plain; charset=us-ascii organization: Lockheed Martin Tactical Aircraft Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.02 (Macintosh; I; 68K) Date: 1996-08-12T00:00:00+00:00 List-Id: Here's a little brain teaser we received recently. Assuming no typos or other obvious syntax errors, will the Fill procedure work in Ada 83? package Zoo is type Animal_ID is range 1 .. 5; -- yes, an enumeration type might be -- better, but it spoils the example! subtype Cage_ID is Positive range 1 .. 12; type Cage_Row is array (Cage_ID) of Animal_ID; -- Fill fills a row of cages with various animals, in sequential order -- with alternating animals procedure Fill ( Cages : in out Cage_Row ); end Zoo; package body Zoo is procedure Fill ( Cages : in out Cage_Row ) is Next_Animal : Animal_ID := Animal_ID'First; begin -- Fill for Cage in Cages'Range loop Cages(Cage) := Next_Animal; Get_Next_Animal: begin -- look carefully at this code! Next_Animal := Animal_ID'Succ(Next_Animal); exception when others => Next_Animal := Animal_ID'First; end Get_Next_Animal; end loop; end Fill; end Zoo;