Lists and Their Commands

A list is a collection of elements in order. On the TI-68k calculators, lists can contain any mix of any variable type that's valid in an expression: you can have lists of numbers, lists of strings, lists of truth values or expressions. You can even mix and match variable types — it's perfectly all right to have a string in one element, and a number in the next. The only special case is lists of lists: these are kind of allowed, but they're called matrices, and have some further restrictions.

Lists are written using curly brackets { and } around the elements, separated by commas. For example, {1,2,3,4,5} is a list containing the numbers 1 through 5 in that order. You can access a certain element of the list by writing the number of the element you want in [ ] brackets after it: listvar[5] would select the 5th element of listvar. Elements are numbered starting with 1.

On earlier calculator models, lists had the random access property: accessing any element of a list took the same amount of time. This was possible because the lists were restricted to numbers. On the 68k calculators, since lists can mix element types, they are no longer random access: the calculator has to go through the entire list to get to an element, so the larger an index is, the longer it takes to access. This isn't significant for short lists. But taking the 100th element, for example, takes approximately twice as long as taking the 1st element, and the time keeps increasing linearly, so it can be very slow to access the last elements of a long list.

Except for the constraint of free memory, and of the time it takes to access elements, there is no limit on the number of elements a list may have.

Operations on Lists

Many commands, including math commands and others, can be extended to lists by applying them to each element of the list. An example is sin():

    {sin(1) sin(2) sin(3)}

If a command has more than one argument, there are two ways to extend it to apply to lists. One is to use it with a list and a regular argument: then the command will be applied to each element of the list paired up with the regular argument. Here is this way illustrated with mod()
    {3 6 2}

The other way is to make both arguments lists. In that case, the lists must be the same size, and each element of the first list will be paired with the corresponding element of the second. For example:
    {3 4 3}

Although in these examples, mod() could be extended in both ways, sometimes only one is possible. PtOn, for example, (as well as other point commands) can be used with two numbers, or two lists, but not with a list and a number. round(), on the other hand, can be used with two numbers, or a list and a number, but will give a meaningless expression when applied to two lists.

A noteworthy special case is the basic math operators (+, -, *, /, , and ^), which can all be used with lists (in both ways).

List-Specific Commands

Of course, there are commands specifically designed for use with lists. Several of these, such as dim() or rotate(), can be also used with strings. Many of these commands are found in the list menu (Press 2nd MATH to access the popup math menu, then select 3:List).

Several statistics commands can be applied to lists as well.

Conditionals With Lists

Conditional statements, like If, when(), and While, accept lists of truth values as well as single truth values. The check will be interpreted as true if and only if every element of the list is true, effectively combining each element of the list with and.

The most common way for lists of truth values to be created is with relational operators (=, , >, , <, ) applied to lists. They will return the single value ' false' unless both sides of the relation are lists of equal size, in which case the lists will be compared element by element, returning a list.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.