Returns the size of a list, matrix, or string.
dim(list-matrix-or-string)
Menu Location
- Press 2nd MATH to enter the MATH menu.
- Press D to enter the String submenu.
- Press 3 to select dim(.
This command works on all calculators.
1 byte
The dim() command returns the size of a list, matrix, or string:
- The number of elements for a list.
- The number of characters for a string.
- A list of {number of rows or columns} for a matrix.
This command is critical to using any of these objects, for instance, if you want to write a For..EndFor loop to look at every element.
However, unlike the TI-83 series version, you can't use the dim() command to change the size of anything. Use mid() to get a smaller list or string (subMat() for a matrix), or use newList() and newMat() to create a list or matrix of a specific size.
:dim({1,2,3,4,5}
5
:dim("TI-Basic Developer")
18
:dim([1,2,3;4,5,6])
{2 3}
Optimization
For matrices, using rowDim() and colDim() is usually better in all practical situations, and you don't have to remember which number goes first.