|
1 | 1 | import { GeneralRuntimeError, InvalidParameterTypeError } from '@sourceacademy/modules-lib/errors'; |
2 | | -import { assertFunctionOfLength, assertNumberWithinRange, isFunctionOfLength, isNumberWithinRange } from '@sourceacademy/modules-lib/utilities'; |
| 2 | +import { assertFunctionOfLength, assertNumberWithinRange, isFunctionOfLength, isNumberWithinRange, wrapFunction } from '@sourceacademy/modules-lib/utilities'; |
3 | 3 | import { head, is_pair, pair, tail, type List, type Pair } from 'js-slang/dist/stdlib/list'; |
4 | 4 | import { Matrix, type CellCallback } from './types'; |
5 | 5 |
|
@@ -38,9 +38,11 @@ export const MAX_COLS: number = 256; |
38 | 38 | * Creates a 2D matrix with the given number of rows and columns |
39 | 39 | * @param rows Number of rows between 1 and {@link MAX_ROWS} |
40 | 40 | * @param cols Number of columns between 1 and {@link MAX_COLS} |
| 41 | + * @param name Optional name for the matrix |
41 | 42 | * @returns Matrix |
| 43 | + * @function |
42 | 44 | */ |
43 | | -export function create_matrix(rows: number, cols: number, name: string | undefined): Matrix { |
| 45 | +export const create_matrix = wrapFunction((rows: number, cols: number, name?: string): Matrix => { |
44 | 46 | assertNumberWithinRange(rows, create_matrix.name, 1, MAX_ROWS, true, 'rows'); |
45 | 47 | assertNumberWithinRange(cols, create_matrix.name, 1, MAX_COLS, true, 'cols'); |
46 | 48 |
|
@@ -69,7 +71,7 @@ export function create_matrix(rows: number, cols: number, name: string | undefin |
69 | 71 | cols, |
70 | 72 | [], |
71 | 73 | ); |
72 | | -} |
| 74 | +}, 1); |
73 | 75 |
|
74 | 76 | /** |
75 | 77 | * Creates a copy of an existing matrix. The copy will not have the existing's registered buttons |
|
0 commit comments