|
We're glad you came by, but you might find what you're looking for elsewhere. TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it. Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope. |
Returns the index number of an element searched for within a list
X - Element that it's finding
L₁ - List that's being searched
N - The occurrence to search for
Ans - Index number of element searched.
{$variable}
TI-83/84/+/SE/CSE/CE
RogueBantha, CubeBag
//Finds first occurrence of X in L₁
1+sum(not(cumSum(L₁=X
//Finds last occurrence of X in L₁
max((L₁=X)cumSum(1 or L₁
// Finds the Nth occurrence of X in L₁
1+sum(N>cumSum(L₁=XGiven a value in X, this code will search L₁ and return the index number of the desired occurrence of X.
Error Conditions
If L₁ does not contain X, the first and third routines will both return 1+dim(L₁); the second will return zero.
.