[BACK]Return to generate_unions.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / Root_Counts / Product

File: [local] / OpenXM_contrib / PHC / Ada / Root_Counts / Product / generate_unions.adb (download)

Revision 1.1, Sun Oct 29 17:45:29 2000 UTC (23 years, 8 months ago) by maekawa
Branch point for: MAIN

Initial revision

procedure Generate_Unions ( k,first,last : in integer ) is

  acc : boolean_array(first..last) := (first..last => false);
  cont : boolean := true;

  procedure Generate ( k,start,last : in integer;
                       acc : in out boolean_array ) is
  begin
    if k = 0
     then process(acc,cont);
     elsif k > last - start + 1
         then return;
         else for i in start..last loop
                acc(i) := true;
                generate(k-1,i+1,last,acc);
                exit when not cont;
                acc(i) := false;
              end loop;
    end if;
  end Generate;

begin
  Generate(k,first,last,acc);
end Generate_Unions;