Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Ada how do I initialise an array constant with a repeated number?

I need an array of 820 zeros for using with a mathematical function.

In C I could just write the following and the compiler would fill the array:

 const float EMPTY_NUMBER_A[820] = { 0.0, };

However in Ada that isn't possible. I really don't want to hard code the 820 elements as 0.0. Is there a way to get the compiler to do it?

 type Number_A is array (1 .. 820) of Float;
 EMPTY_NUMBER_A : constant Number_A := ???;

Using Ada 95 and GNAT.

like image 611
mat_geek Avatar asked Oct 22 '25 21:10

mat_geek


1 Answers

Use an aggregate:

Empty_Number_A : constant Number_A := (others => 0.0);
like image 88
Marc C Avatar answered Oct 25 '25 10:10

Marc C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!