Ohai. Say I have a list:

{23,76,45,99,129}

And I want to figure out which position like an item is. (Like 45 is 3)

How would I do that?

Let's say your list is in L1. This is how you'd do it:

:max((L1=45)cumSum(binomcdf(dim(L1)-1,0

Sure it doesn't make sense, but it works. =)

This is what it looks like step by step, if you want to understand how it works:

max((L1=45)cumSum(binomcdf(dim(L1)-1,0

max(({23,76,45,99,129}=45)cumSum({1,1,1,1,1

max({0,0,1,0,0}*{1,2,3,4,5

max({0,0,3,0,0

3

Good luck!

Find more info about my projects on Omnimaga:

http://www.omnimaga.org/index.php

Two faster methods (reference):

1. `L1=Ans:max(AnscumSum(not(0Ans`

2. `L1=Ans:max(AnscumSum(1 or Ans`

Using…

`startTmr→T
For(X,1,3E3)
max(L1cumSum(1 or L1 -or- not(0L1
End
checkTmr(T`

…#2 was about 4 seconds^{†} faster than #1 over 3000 iterations on my 84+SE. The fact that #1 contained one more operation than #2 wasn't necessarily enough to validate this, but it offered incentive for me to investigate.

^{†}(This is dependent on `L1` being a list of five elements; one element sufficed to save just one second over 3000 iterations.)

Now, I'm almost certain that I will sit back and watch the wrong *slower* one being used, anyhow…

We are of course assuming that the element will not possibly occur twice in a list, right?

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

Thank you for the help guys. And yes, no element will occur twice. @Weregoose, I will try to use the faster method once I have time to comprehend it.

And I always thought that cumSum was useless. Where do you guys come up with this stuff? This is amazing…

EDIT: I forgot ask, but the TI-89 — I think when using a conditional statement, it considers neither 1 nor 0 to be true or false. If that makes any sense. Is there a way to get around this? It seems that a lot of programs rely on the fact that 0 is false and 1 is true.

If you can guarantee that the list will be sorted you can use a binary tree which will be faster for large lists but slower then ztrumpets method for small ones. I haven't done run time tests so I can't tell how large the list has to be for this method to be faster. here is my binary tree code

`define binsrch(v,s)=func
:local t,b
:{1,dim(s)}→b
:While b[1]≤b[2]
:int(mean(b))→t
:If s[t]=v
:Return t
:t→b[iffn(s[t]<v,1,2)]
:EndWhile
:Return 0`

returns index if it exists or 0 if the number in not in the list