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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,100c539a37d7d2e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-15 06:18:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!freenix!usenet-fr.net!gaoland.net!alecto.grec.isp.9tel.net!not-for-mail From: "Zeg" Newsgroups: comp.lang.ada Subject: Re: chained List manipulation without recusrsion : lost the begining of my List! Date: Thu, 15 May 2003 15:16:04 +0200 Organization: 9Telecom Message-ID: References: NNTP-Posting-Host: 27.169.62.62.9massy1-1-ro-bas-1.9tel.net X-Trace: aphrodite.grec.isp.9tel.net 1053004626 23909 62.62.169.27 (15 May 2003 13:17:06 GMT) X-Complaints-To: abuse@9online.fr NNTP-Posting-Date: Thu, 15 May 2003 13:17:06 +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:37343 Date: 2003-05-15T15:16:04+02:00 List-Id: I missed inserting at the head of the List so this the ultimate code procedure Insert_iteratif(E : in Element; L : in out Liste) is Aux : Liste := L; Z : Liste; begin if (L = null) then L := new Maillon'(E,null); else while (Aux /= null) loop if (Aux.all.valeur > E) then if (z = null) then L := new Maillon'(E,L); else z.all.suivant := new Maillon'(E,Aux); end if; exit; elsif (Aux.all.suivant = null) then z.all.suivant := new Maillon'(E,null); exit; end if; z := Aux ; Aux := Aux.all.suivant; end loop; end if; end Insert_iteratif; "Simon Wright" a �crit dans le message de news:x7vfzngg39y.fsf@smaug.pushface.org... > "Zeg" writes: > > > procedure Insert_iteratif(E : in Element; L : in out Liste) is > > Aux : Liste := L; > > Z : Liste := null; > > You don't need to initialize access variables, they are automatically > set to null for you > > > begin > > if (Aux = null) then > > Aux := new Maillon'(E,null); > > L was empty, so what is it pointing to now? Should you have altered it? > > > else > > while (Aux /= null) loop > > if (Aux.all.valeur > E) then > > L := new Maillon'(E,Aux); > > What has happened to all the previous elements in the list? (that L > used to be pointing to) > > > exit; > > elsif (Aux.all.suivant = null) then > > L:= new Maillon'(E,null); > > What has happened to all the previous elements in the list? > > > exit; > > end if; > > z := Aux ; > > What is Z for? You don't read it anywhere > > > Aux := Aux.all.suivant; > > end loop; > > end if; > > > > end Insert_iteratif; > > It might help you to draw a picture of Maillons linked into a Liste, > and how you want a new Maillon to be linked in.