-- Code of Figure 6.4, pages 208-209 from -- Kenneth C. Louden, Programming Languages -- Principles and Practice 2nd Edition -- Copyright (C) Brooks-Cole/ITP, 2003 with Text_IO; use Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure ArrTest is type IntToInt is array (INTEGER range <>) of INTEGER; function array_max(a: IntToInt) return integer is temp: integer; begin temp := a(a'first); -- first subscript value for a -- a'range = set of legal subscripts for i in a'range loop if a(i) > temp then temp := a(i); end if; end loop; return temp; end array_max; size: integer; begin put_line("Input a positive integer: "); get(size); declare x: IntToInt(1..size); -- dynamically sized array max: integer; begin for i in x'range loop -- x'range = 1..size x(i) := i; end loop; put(array_max(x)); new_line; end; end ArrTest;