How can I check the to see if an element of an array exists in Ada. Also is there any good documented site for Ada like python’s or php’s documentation sites, so that I can search for all the types of functions and it’s uses. I am not able to find more information in google for some types of functions in Ada.
soldiers : array (0..max_number_of_soldiers - 1) of soldier_type;
procedure Next (Index: in out Integer; Interval: Positive) is
begin
for I in 1..Interval loop
loop
Index := (Index + 1) mod Number_Of_Soldiers;
exit when Soldiers(Index).Alive;
end loop;
end loop;
end Next;
what does Soldiers(Index).Alive shows ? What is .alive ?
The exact type definition of
soldier_typeis missing, but apparently it’s got a (boolean)alivefield.There’s an array of
max_number_of_soldierssoldiers. This code iterates through the array, and exits when it finds a soldier that’s alive.It starts at index
Index, and loops throughIntervalitems. If it reaches the end, it wraps and starts at the start of the array.So, to answer your question, Soldiers(Index).Alive returns whether the solder at
indexis alive or not.