September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -2,27 +2,21 @@ with Ada.Text_IO, Ada.Command_Line;
use Ada.Text_IO, Ada.Command_Line;
procedure powerset is
procedure print_subset (set : natural) is
-- each i'th binary digit of "set" indicates if the i'th integer belongs to "set" or not.
k : natural := set;
first : boolean := true;
begin
Put ("{");
for i in 1..Argument_Count loop
if k mod 2 = 1 then
if first then
first := false;
else
Put (",");
end if;
Put (Argument (i));
end if;
k := k / 2; -- we go to the next bit of "set"
end loop;
Put_Line("}");
end print_subset;
begin
for i in 0..2**Argument_Count-1 loop
print_subset (i);
end loop;
for set in 0..2**Argument_Count-1 loop
Put ("{");
declare
k : natural := set;
first : boolean := true;
begin
for i in 1..Argument_Count loop
if k mod 2 = 1 then
Put ((if first then "" else ",") & Argument (i));
first := false;
end if;
k := k / 2; -- we go to the next bit of "set"
end loop;
end;
Put_Line("}");
end loop;
end powerset;