with Ada.Text_Io; use Ada.Text_Io;
with Ada.Unchecked_Deallocation;

procedure Dico is 
   
   -- Types
   type Dico;
   type Lien is access Dico;
   type Tab_Lien is array (Character range 'a'..'z') of Lien;
   type Dico is record
      Mot : Boolean;
      Lettres : Tab_Lien;
   end record;
   
   -- Free
   procedure Free is new Ada.Unchecked_Deallocation(Dico, Lien);
   
   -- Procédure d'init.
   procedure Init(D : out Dico) is
   begin
      D.Mot := False;
      
      -- Pas obligatoire, mais on peut free l'espace vide:
      for I in D.Lettres'Range loop
	 Free(D.Lettres(I));
      end loop;
   end Init;
   
   function Appartient(M : in String; Dic : in Dico) return Boolean is
   begin
      if M'Length <= 0 then
	 return False;
      elsif M'Length = 1 and then Dic.Lettres(M(M'Last)).Mot then
	 return True;
      elsif Dic.Lettres(M(M'First)) /= null then
	 return Appartient_lien(M(M'First+1..M'Last), Dic.Lettres(M(M'First)).all);
      else
	 return False;
      end if;
   end Appartient;
   
   
begin
   null;
end Dico;
