-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfizz_buzz_2.adb
37 lines (31 loc) · 979 Bytes
/
fizz_buzz_2.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
with Ada.Text_IO; use Ada.Text_IO;
procedure Fizz_Buzz_2 is
Fizz : aliased constant String := "Fizz";
Buzz : aliased constant String := "Buzz";
Fizz_Buzz : aliased constant String := Fizz & Buzz;
type String_Access is access String;
subtype Threes is boolean;
subtype Fives is boolean;
type String_Tables is array (Threes, Fives) of String_Access;
-- 5 F T
-- 3 |----
-- F | n b
-- T | f x
String_Table : constant String_Tables := (
(null, Buzz'Unrestricted_Access),
(Fizz'Unrestricted_Access, Fizz_Buzz'Unrestricted_Access)
);
begin
for Count in 1 .. 100 loop
declare
Text : constant String_Access := String_Table (Count rem 3 = 0, Count rem 5 = 0);
begin
-- Put (Integer'Image (Count));
if Text /= null then
Put_Line (Text.all);
-- else
-- New_Line;
end if;
end;
end loop;
end Fizz_Buzz_2;