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,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,100c539a37d7d2e6,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-14 16:22:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!usenet-fr.net!gaoland.net!alecto.grec.isp.9tel.net!not-for-mail From: "Zeg" Newsgroups: comp.lang.ada Subject: chained List manipulation without recusrsion : lost the begining of my List! Date: Thu, 15 May 2003 01:20:42 +0200 Organization: 9Telecom Message-ID: NNTP-Posting-Host: 27.169.62.62.9massy1-1-ro-bas-1.9tel.net X-Trace: aphrodite.grec.isp.9tel.net 1052954501 11775 62.62.169.27 (14 May 2003 23:21:41 GMT) X-Complaints-To: abuse@9online.fr NNTP-Posting-Date: Wed, 14 May 2003 23:21:41 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Xref: archiver1.google.com comp.lang.ada:37336 Date: 2003-05-15T01:20:42+02:00 List-Id: Hi all, I'm trying to make a procedure to insert an integer (at this natural position) in a chained List without recursion but each time I lost the begining of my List, i understand why but i don't find the trick. I think it would be very easy for most of you, Thanks in Advance . Zeg type Element is new Integer; type Maillon; type Liste is access Maillon; type Maillon is record Valeur : Element; Suivant : Liste := null; end record; procedure Insert_iteratif(E : in Element; L : in out Liste) is Aux : Liste := L; Z : Liste := null; begin if (Aux = null) then Aux := new Maillon'(E,null); else while (Aux /= null) loop if (Aux.all.valeur > E) then L := new Maillon'(E,Aux); exit; elsif (Aux.all.suivant = null) then L:= new Maillon'(E,null); exit; end if; z := Aux ; Aux := Aux.all.suivant; end loop; end if; end Insert_iteratif; --======================== begin L := new Maillon'( 3,new Maillon'(4,new Maillon'(5,new Maillon'(7,new Maillon'(8,new Maillon'(10,new Maillon'(99,null))))))); Insert_iteratif(9,L); end --=======================