Power set: Difference between revisions

m
Line 123:
 
<lang Ada>
with adaAda.text_ioText_IO, Ada.Command_Line;
use Ada.Text_IO, Ada.Command_Line;
 
procedure powerset is
Line 131 ⟶ 132:
first : boolean := true;
begin
Ada.Text_IO.putPut ("{");
for i in 1..Ada.Command_Line.Argument_Count loop
if k mod 2 = 1 then
if first then
first := false;
else
Ada.Text_IO.putPut (",");
end if;
Ada.Text_IO.putPut (Ada.Command_Line.Argument (i));
end if;
k := k / 2; -- we go to the next bit of "set"
end loop;
Ada.Text_IO.put_linePut_Line("}");
end print_subset;
begin
for i in 0..2**Ada.Command_Line.Argument_Count-1 loop
print_subset (i);
end loop;
Anonymous user