Skip to content

Instantly share code, notes, and snippets.

@BitPuffin
Created November 23, 2013 18:41
Show Gist options
  • Save BitPuffin/7618340 to your computer and use it in GitHub Desktop.
Save BitPuffin/7618340 to your computer and use it in GitHub Desktop.
proc `{}`*[T; R, C](m: TMatrix[T, R, C], n: range[0..99]): TMatrix[T, R.low..R.high-1, C.low..C.high-1] {.noSideEffect.} =
## Returns the submatrix of the given matrix
## m{23} deletes row 2 and column 3 and returns the result.
let r = n div 10 mod 10
let c = n mod 10
for i in R.low..R.high:
if i == r:
continue
for j in C.low..C.high:
if j == c:
continue
let ro = if i < r: i else: i - 1
let co = if j < c: j else: j - 1
result[ro][co] = m[i][j]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment