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,a644fa9cd1a3869a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-20 04:50:23 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!195.54.122.107!newsfeed1.bredband.com!bredband!newsfeed.gamma.ru!Gamma.RU!peer.news.eu-x.com!server2.netnews.ja.net!newshost.central.susx.ac.uk!news.bton.ac.uk!not-for-mail From: John English Newsgroups: comp.lang.ada Subject: Re: List container: Insert and Delete Date: Tue, 20 Nov 2001 10:52:56 +0000 Organization: University of Brighton Message-ID: <3BFA3608.D1B62548@brighton.ac.uk> References: <9sn4qm$13g29j$2@ID-25716.news.dfncis.de> <3BF140D9.611DE43@brighton.ac.uk> <9srvmk$1la$1@news.huji.ac.il> <3BF2699A.731DC436@brighton.ac.uk> <9su77k$c83$1@news.huji.ac.il> <3BF3F4E9.7E32361B@brighton.ac.uk> <%tbK7.30443$xS6.49650@www.newsranger.com> NNTP-Posting-Host: pc2je.it.bton.ac.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: saturn.bton.ac.uk 1006257084 17886 193.62.183.154 (20 Nov 2001 11:51:24 GMT) X-Complaints-To: news@bton.ac.uk NNTP-Posting-Date: 20 Nov 2001 11:51:24 GMT X-Mailer: Mozilla 4.7 [en-gb] (Win95; U) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:16714 Date: 2001-11-20T11:51:24+00:00 List-Id: Ted Dennison wrote: > > In article <3BF3F4E9.7E32361B@brighton.ac.uk>, John English says... > >Missing from Ted's Strawman: Clear(L) = delete everything in the list, > > I think that's far more important in your version than it is in the Strawman > because you use a limited type. With a limited type, the only way for someone to > reuse a list variable on a new list is to delete everything out of the old one. > With a non-limited list, you can just build your new list and assign it in. Uh huh. True, I made it limited because I didn't want to talk about controlled types at that point in the book, but non-limited (shallow copy semantics) is probably better. > >Cut(A,B) = remove everything between iterators A and B and return as > >a list (or raise List_Error if A and B refer to separate lists), and > >Copy(A,B) = copy a sublist. The use of Cut and Copy together with "&" > >and Insert(Iterator,List) would deal with all the sublist operations > >and operations on pairs of lists. > > What do you have to do a lot that requires this? They can both be built with the > provided iterators without loosing much processing power. I'm thinking of the equivalent of A(1..N) := A(I+1..N) & A(1..I); > >Problems encountered: students don't like Delete(Pred(Last(L))), > >they always write Delete(Last(L)) and then get a List_Error. > > I'd think the "Pop" operations would be the more standard (and popular) way of > removing items off of one of the ends of the list than going though the effort > of using the active iterator routines. I'd certainly agree in this case! ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.comp.it.bton.ac.uk/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk -----------------------------------------------------------------