Power set: Difference between revisions

Content added Content deleted
Line 123: Line 123:


<lang Ada>
<lang Ada>
with ada.text_io, Ada.Command_Line;
with Ada.Text_IO, Ada.Command_Line;
use Ada.Text_IO, Ada.Command_Line;


procedure powerset is
procedure powerset is
Line 131: Line 132:
first : boolean := true;
first : boolean := true;
begin
begin
Ada.Text_IO.put ("{");
Put ("{");
for i in 1..Ada.Command_Line.Argument_Count loop
for i in 1..Argument_Count loop
if k mod 2 = 1 then
if k mod 2 = 1 then
if first then
if first then
first := false;
first := false;
else
else
Ada.Text_IO.put (",");
Put (",");
end if;
end if;
Ada.Text_IO.put (Ada.Command_Line.Argument (i));
Put (Argument (i));
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;
Ada.Text_IO.put_line("}");
Put_Line("}");
end print_subset;
end print_subset;
begin
begin
for i in 0..2**Ada.Command_Line.Argument_Count-1 loop
for i in 0..2**Argument_Count-1 loop
print_subset (i);
print_subset (i);
end loop;
end loop;