mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
1 line
1.5 KiB
Beef
Executable File
1 line
1.5 KiB
Beef
Executable File
fprintf (stdout, "\n1). Spawning a zero-populated 5x6 matrix and setting it's values to random numbers in [0,1].\n");
|
|
aMatrix = {5,6};
|
|
aMatrix = aMatrix ["Random(0,1)"];
|
|
fprintf (stdout, aMatrix, "\n");
|
|
|
|
fprintf (stdout, "\n2). Accessing a second-row third-column element and a random element.\n\n");
|
|
r = Random (0, Rows(aMatrix))$1;
|
|
c = Random (0, Columns(aMatrix))$1;
|
|
fprintf (stdout, "matrix[1][2]=", aMatrix[1][2], "\nmatrix[", r , "][" , c, "]=", aMatrix[r][c], "\n");
|
|
|
|
fprintf (stdout, "\n3). Accessing the fourth row.\n\n");
|
|
fprintf (stdout, "matrix[3][-1]=\n", aMatrix[3][-1],"\n");
|
|
|
|
fprintf (stdout, "\n4). Accessing the first column.\n\n");
|
|
fprintf (stdout, "matrix[-1][0]=\n", aMatrix[-1][0],"\n");
|
|
|
|
fprintf (stdout, "\n5). Populating a matrix template (below the diagonal).\n\n");
|
|
template={5,6};
|
|
template=template["_MATRIX_ELEMENT_ROW_>_MATRIX_ELEMENT_COLUMN_"];
|
|
fprintf (stdout, template ,"\n");
|
|
|
|
fprintf (stdout, "\n6). Extracting (by row) matrix elements using the template.\n\n");
|
|
fprintf (stdout, aMatrix[template] ,"\n");
|
|
|
|
fprintf (stdout, "\n7). Extracting a submatrix: top left corner at (1,1) - bottom right corner at (3,2).\n\n");
|
|
fprintf (stdout, "matrix[{{1,1}}][{{3,2}}]=\n", aMatrix[{{1,1}}][{{3,2}}],"\n");
|
|
|
|
fprintf (stdout, "\n8). Returning a matrix in which all elements are squared and above diagonal elements are further increased by 1.\n\n");
|
|
fprintf (stdout, "\n", aMatrix["_MATRIX_ELEMENT_VALUE_^2+(_MATRIX_ELEMENT_ROW_<_MATRIX_ELEMENT_COLUMN_)"],"\n");
|
|
|