[3.19] Test A List For Identical Elements; [3.20] Find Matrix Minimum And Maximum - Texas Instruments TI-89 Tip List

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

This is a well known way to exchange two elements. I include it only because you might be tempted, as
I was, to do it in a more convoluted way. Note that this function takes advantage of the fact that you
can write to the function arguments. In this case, the elements of list are written directly to list, then list
is returned.
This function executes in about 0.17 seconds on a TI92+ with AMS 2.05. For even better speed, don't
call the function, just use the three lines that perform the swap. Those three lines execute in about
0.099 seconds.

[3.19] Test a list for identical elements

If you need to know if all the elements of a list are identical, try this function:
lstident(l)
Func
©(list) return true if all elements of 'list' are the same
©18jan01/dburkett@infinet.com
when(„list(l)=newlist(dim(l)-1),true,false)
EndFunc
The function returns true if all the list elements are equal, and false otherwise. The basic idea is to use
„list()
to create a list of the differences between the elements, then compare that result to a list of
zeros.
This function works if the list elements are numbers (including complex numbers) or strings, but does
not work if the list elements are expressions. If the elements are all the same expression, lstident()
returns true, but if the elements are not the same, lstident() returns itself. It is a little odd that this
method works for lists of strings, since newlist() returns a list with all zero elements, but
„list("a","a","a")
and
„list("a","a","b")
Since "b-a" is a string, and strings test as 'not equal' to numbers, it works.
Note that the when() function is necessary, otherwise the expression will return a list of true and false
elements, instead of a single true or false.

[3.20] Find matrix minimum and maximum

The built-in functions min() and max() return a row vector whose elements are the minimum and
maximum, respectively, of the matrix rows. If you need the single minimum or maximum matrix
element, use this to find the minimum matrix element of matrix mat1
min(mat▶list(mat1))
and this to find the maximum matrix element
max(mat▶list(mat1))
{0,0}
returns
{0,"b-a"}
returns
3 - 19

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents