Computer Programming with the Nim Programming Language
= array[Rows, Fig] Board = array[Cols, Col] var b: Board const a = 0 rook = 5 # whatever makes sense b[a][0] = rook echo b[a][0] # 5 # with user-defined templates we can simplify the index notation int): int8 = b[i][j] template `[]=`(b: var Board; i, j: int; v: int8) = b[i][j] = v b[a, 0] = rook echo b[a, 0] # 5 Now, let’s investigate the case where one or both dimensions of the matrix can0 码力 | 865 页 | 7.45 MB | 1 年前3
Computer Programming with the Nim Programming Language
= array[Rows, Fig] Board = array[Cols, Col] var b: Board const a = 0 rook = 5 # whatever makes sense b[a][0] = rook echo b[a][0] # 5 # with user-defined templates we can simplify the index notation int): int8 = b[i][j] template `[]=`(b: var Board; i, j: int; v: int8) = b[i][j] = v b[a, 0] = rook echo b[a, 0] # 5 Now, let’s investigate the case where one or both dimensions of the matrix can0 码力 | 784 页 | 2.13 MB | 1 年前3
共 2 条
- 1













