Your error message makes no sense for me, and your proc compiles fine for me:
type
Matrix*[W, H: static int] = array[W, array[H, float]]
func xsubmatrix*[W, H](m: Matrix[W, H]): Matrix[W - 1, H - 1] =
for row in 0 ..< high(m):
for col in 0 ..< high(m[0]):
result[row][col] = m[row][col]
# Remove specified row and column
func submatrix*[W, H](m: Matrix[W, H], rowIdx, colIdx: int): Matrix[W - 1,
H - 1] =
for row in 0 .. high(m):
var resultRow = row
if row == rowIdx: continue
elif row > rowIdx: resultRow.dec(1)
for col in 0 .. high(m[0]):
var resultCol = col
if col == colIdx:
continue
elif col > colIdx: resultCol.dec(1)
result[resultRow][resultCol] = m[row][col]
var
m: Matrix[3, 3]
let s = submatrix(m, 1, 1)
echo s.len
echo s[0].len
Run
$ nim c -r t.nim
Hint: used config file '/home/stefan/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/stefan/Nim/config/config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: t [Processing]
Hint: [Link]
Hint: 21948 LOC; 0.167 sec; 24.613MiB peakmem; Debug build; proj:
/tmp/hhh/t.nim; out: /tmp/hhh/t [SuccessX]
Hint: /tmp/hhh/t [Exec]
2
2
stefan@nuc /tmp/hhh $ nim -v
Nim Compiler Version 1.1.1 [Linux: amd64]
Compiled at 2020-03-13
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: 9eeb514dda08f1caadb0d8e01a8595d991530b52
active boot switches: -d:release
stefan@nuc /tmp/hhh $
Run