Texas Instruments TI-89 Tip List page 115

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

Advertisement

// throw the appropriate error if the user enters too many or
// too few arguments, or doesn't enter a LIST or MATRIX
if (argumentNumber > 2)
ER_throwVar (940);
if (argumentNumber < 2)
ER_throwVar (930);
if (*listPointer != LIST_TAG)
ER_throwVar (90);
// get a pointer to the second argument
itemPointer = next_expression_index (listPointer);
// decrement listPointer so it points to first element in list
listPointer--;
// designate the end of the list of indices that will be
// pushed to the expression stack
push_quantum (END_TAG);
// step through the list, examining each element to see
// if it matches target item; if it does, add its
// position to the list
while (*listPointer != END_TAG)
{
// compare_expressions returns 0 if the items match
if (compare_expressions(listPointer, itemPointer) == 0)
push_longint (index);
// advance pointer to the next element
listPointer = next_expression_index (listPointer);
index++;
}
// list on the top of the stack is in descending order, so
// reverse the list so items are in ascending order
push_reversed_tail (top_estack);
push_quantum (LIST_TAG);
// estack clean up
itemPointer = next_expression_index (top_estack);
while (*itemPointer != END_TAG)
{
listPointer = itemPointer;
itemPointer = next_expression_index (itemPointer);
delete_expression (listPointer);
}
} // main
(Credit to Brett Sauerwein for the C version)
3 - 33

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents