-- Demonstrates 
--      constrained arrays with anonymous types
--      aggregate array assignment
--  Array bounds are fixed.  They can never change.  (But see unconstrained array types)

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

procedure array0 is
    -- Assume cats and dogs at locations from -3 up to 3.
    -- Cat counts are not initialized, dog counts are.

    -- Constrained arrays (ie they have bounds) with anonymous types (ie no named type)
    cat_count: array(-3 .. 3) of Natural;
    dog_count: array(-3 .. 3) of Natural := (-2 |  0 | 2 => 1, others => 0);

    total_animals: Natural := 0;
begin
    -- Assign values for the cats using an aggregate assignment (value in parentheses)
    cat_count := (-3 | 3 => 1, -1 | 1  => 2, others => 0);

    for i in -3 .. 3 loop
        put(i);
        put(cat_count(i));
        put_line(dog_count(i)'img);
    end loop;

    for i in -3 .. 3 loop
        total_animals := total_animals + cat_count(i) + dog_count(i);
    end loop;

    put_line(total_animals'img);

end array0;

-- Output: 
--|         -3          1 0
--|         -2          0 1
--|         -1          2 0
--|          0          0 1
--|          1          2 0
--|          2          0 1
--|          3          1 0
--| 9