Created
November 23, 2013 18:41
-
-
Save BitPuffin/7618340 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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