Power set: Difference between revisions
Content added Content deleted
m (→{{header|Ada}}) |
|||
Line 123: | Line 123: | ||
<lang Ada> |
<lang Ada> |
||
with |
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 |
||
Put ("{"); |
|||
for i in 1. |
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 |
||
Put (","); |
|||
end if; |
end if; |
||
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; |
||
Put_Line("}"); |
|||
end print_subset; |
end print_subset; |
||
begin |
begin |
||
for i in 0..2** |
for i in 0..2**Argument_Count-1 loop |
||
print_subset (i); |
print_subset (i); |
||
end loop; |
end loop; |