-- Demonstrates 
--      unconstrained array types - a named type without specific bounds
--      unconnstrained array types as parameters - can call with different sizes

with ada.text_io; use ada.text_io;
with ada.integer_text_io; use ada.integer_text_io;

procedure array3 is
    type int_array_t is array(Natural range <>) of Natural;

    -- Read array values from standard input
    -- Works for any size array
    procedure fill(ia: out int_array_t) is
    begin
        for i in ia'range loop
            get(ia(i));
        end loop;
    end fill;

    -- Works for any size array
    function total(ia: in int_array_t) return Natural is
        ans: Natural := 0;
    begin
        for i in ia'range loop
            ans := ans + ia(i);
        end loop;

        return ans;
    end total;

    some_ints: int_array_t(1 .. 3);   -- Two arrays of same type but different sizes
    more_ints: int_array_t(1 .. 8);

begin
    fill(some_ints);
    fill(more_ints);

    put(total(some_ints)'img);
    put(total(more_ints)'img);
end array3;

-- Input: 1 2 3     11 22 33 44 55 66 77 88
-- Output: 6 396