So, I've been making lots of programs that take number key input from people, and lots of times I do something involving converting K=92 to 1, K=82 to 4, etc., but I think the most efficient way would be to iterate through a list of getKey values (ex. ʟKEYSθ={92,93,94,82,83,84}) and return the index of value K. Essentially, if I press the [1] key, the program should search through the list and return what index 92 was in (and so on).

In JavaScript, you would do "list.indexOf(value)", so I'm asking if there's an equivalent to that in TI-Basic. I had another question, but I forgot what it was. I'll edit the post once I remember.

Edit: Jacobly showed the equivalent (And it works!): max((list=K)cumSum(1 or list
The routine provided by Jacobly is great for the general case, but if you're specifically making a numpad reader, this routine would be more efficient both in terms of size and speed.

Code:
`(K≠102)(K-65-13(int(.1K-7`

This also works. Thank you both for your help!

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» All times are UTC - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum