[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.1.1 (vendor branch), Sun Oct 29 17:45:29 2000 UTC (23 years, 8 months ago) by maekawa
Branch: PHC, MAIN
CVS Tags: v2, maekawa-ipv6, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, HEAD
Changes since 1.1: +0 -0 lines

Import the second public release of PHCpack.

OKed by Jan Verschelde.

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;