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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,84e6aecb17a1b669 X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Re: Simple Student Problem Ada83 Date: 1997/04/20 Message-ID: <01bc4dc5$207eacc0$f4f582c1@xhv46.dial.pipex.com>#1/1 X-Deja-AN: 236193324 References: <3358b2bb.2065467@news> <01bc4cd3$f8a7fae0$9bfd1fcc@p5120.bda> Organization: UUNet PIPEX server (post doesn't reflect views of UUNet PIPEX) Newsgroups: comp.lang.ada Date: 1997-04-20T00:00:00+00:00 List-Id: Bob Klungle wrote in article <01bc4cd3$f8a7fae0$9bfd1fcc@p5120.bda>... > Several possibilities come to mind without thinking much. No elegance, just > hack. [hackish solution] Alternatively, (a) suppose the array is called A (b) suppose the number of valid components in A at any particular time is in n (c) suppose the component of A to be deleted is number i a slightly less hackish solution might go along these lines: (1) check that i is not greater than n (what should we do if it is?) (2) copy the components from A(i+1..n) into A(i..n-1) (3) decrement n I will leave coding this into Ada as an exercise, since this is supposed to be an exercise for you! Answer the question posed at the end of (1) - it is an important question. Also, answer the following question. The copy in (2) will be implemented by Ada as a loop, copying the machine elements, let's say bytes, of the array slice specified. This loop will have two 'byte pointers' addressing the byte to be copied from and the byte to be copied to. There are two possible schemes: (1) both pointers are set at their respective last bytes to be copied, and both are decremented; (2) both pointers are set to their respective first bytes and both incremented. Which scheme - (1) or (2) - will be used in this particular example, and why? Nick.