Power set: Difference between revisions

Content added Content deleted
Line 238: Line 238:
begin
begin
for set in 0..2**Argument_Count-1 loop
for set in 0..2**Argument_Count-1 loop
Put ("{");
declare
declare
k : natural := set;
first : boolean := true;
k : natural := set;
first : boolean := true;
begin
begin
Put ("{");
for i in 1..Argument_Count loop
for i in 1..Argument_Count loop
if k mod 2 = 1 then
if k mod 2 = 1 then
Put ((if first then "" else ",") & Argument (i));
Put ((if first then "" else ",") & Argument (i));
first := false;
first := false;
end if;
end if;
k := k / 2; -- we go to the next bit of "set"
k := k / 2; -- we go to the next bit of "set"
end loop;
end loop;
end;
Put_Line("}");
Put_Line("}");
end loop;
end loop;