Got it!! It's a really good exercise to understand pointers and recursivity! Thanks. 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 z.all.suivant := new Maillon'(E,Aux); 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.