Question: Here is a code snippet illustrating my question:

```
const float D    = 0.1F;
const float A[4] = {sin(0*D), sin(1*D), sin(2*D), sin(3*D)};

```

Imagine that global array `A` is much longer and you don't want to do all of this repetitive typing. Is there a shorter way to initialize array A at compile or initialization time, i.e. without having to write initialization function and call it somewhere in my program?

Answer: 
You could initialize A during dynamic initialization time as follows:

```
const float *init_a(float x_)
{
  static float data[4];
  for(unsigned i=0; i<4; ++i)
    data[i]=sin(i*x_);
  return data;
}

const float D=0.1f;
const float *A=init_a(D);

```
You may use code generator to generate initialization code. That is, write program that will write your initialization code for you. You may actually calculate values at generation-time.

Remember that C++ allows placing `,` after last element. It's also isn't necessary to specify array size. These two things should ease writing of generator.

This simple python code should work well:

```
from math import sin

print('const float A[', N, '] = {')
for i in range(N):
    print('\t', sin(i*D), ',', sep='')
print('};')

```