Texas Instruments TI-89 Tip List page 114

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

Advertisement

C version
The TI Basic functions above are functional but slow. The same functionality can be programmed in C,
but the trade-off is increased hassle in that ASM functions, including those written in C, cannot be used
in expressions. Tip [12.2] shows how to get around this by installing a couple of hacks. Note that you
must use the correct version of inlist() for your calculator model: .89z for the TI-89, and .9xz for the
TI-92 Plus.
The C version, inlist(), works the same as indexlst() above for lists. However, for matrices, inlist() is
used to search for a row of elements, and not the individual elements.
An early version of inlist(), which only found a single element occurence, was about 22 times faster
than the equivalent TI Basic version.
The source code for inlist() follows:
/*********************************************************************
This function searches a specified list for a specified item. If the
target item is found, the function returns a list containing the position
of item. If the item is found more than once, the function returns
a list containing all the indices of the target item. If the item is not
found, the function returns an empty list. No restrictions exist on the
types of items in the list.
Error Code Descriptions
90
-- Argument must be a list
930 -- Too few arguments
940 -- Too many arguments
Syntax: inlist(list, item)
inlist(matrix, row)
Since a matrix is defined as a list of lists, this function will also
work with input such as inlist([1,2;2,3], {1,2})
Thanks to Samuel Stearley for his help in optimizing this program.
Brett Sauerwein
15 March 02
********************************************************************/
#define USE_TI89
#define USE_TI92PLUS
#define OPTIMIZE_ROM_CALLS
#define RETURN_VALUE
#include <tigcclib.h>
void _main(void)
{
unsigned char *listPointer, *itemPointer;
int argumentNumber = 0;
int index = 1;
// get a pointer to the first argument entered by the user
InitArgPtr (listPointer);
argumentNumber = remaining_element_count (listPointer);
3 - 32

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents