Q:

How to return an array from a procedure in Nim

I am trying to return an array from a procedure in Nim.  My procedure is as follows,
proc signGen*(n, f0, fs, multi=true): array[cdouble]
 =                                                 
  var signal: array[0..n, cdouble]
  if multi == true:
    for f in 1..int(n/2):
      for s in 1..n:
        signal[s] = sin(f*(2*PI)*s/fs)
        signal[s] += cos(f0 * f *(2*PI) * s / fs)
  else:
    for s in 1..n:
      signal[s] = sin(f*(2*PI)*s/fs)
  return signal

I am getting the following error,
 ~~> nim c -r src/stft.nim                        1 
Hint: used config file '/etc/nim/nim.cfg' [Conf]
Hint: used config file '/etc/nim/config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: stft [Processing]
Hint: lib [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: macros [Processing]
/home/ruste/Development/nim_devel/projects/stft/s
rc/lib.nim(3, 44) Error: array expects two type para
meters 

Any help to troubleshoot this issue is appreciated. 

A:

Array in Nim refers to fixed sized array.  So you need to provide a compile time constant size : array[4, cdouble]. 
If you want a variable size array you need to use seq :
proc signGen*(n, f0, fs, multi=true): seq[cdouble]=

