0
$\begingroup$

Has anyone experienced using TI-89 BASIC programming to solve math problems? I want to create an array using TI-89 but I don't know how?

Update
I tried both

{0, 0, 0, 0}->A 

and

[0, 0, 0, 0]->A 

Basically, I want to create a boolean array to check for duplicate digits of a number.

Update 1

dup(n) Prgm     {0,0,0,0,0,0,0,0,0,0}->a     1->d // digit     While n > 0         mod(10,n)->d         If a[d] = 0 Then 1->a[d]         Else Return 1         EndIf         floor(n/10)->n     EndWhile         Return 0 EndPrgm 

Thanks,
Chan

2 Answers 2

1

I don't have an 89 at hand to check, but I suspect that you can use lists (contained in {}, comma-separated) in much the same way you'd use an array, including subscript-based accessing.


As it turns out, I do have a TI Voyage 200, which is functionally identical to a TI-89 Titanium (runs the same OS, but more memory, better screen, QWERTY keyboard). I am able to store a list into a variable:

{2,4,6,8}->a (where -> is the "sto>" key)

and access items in that list:

a[3] is reformatted as $a_3$ and returns 6.

In what way was {0, 0, 0, 0}->A not working for you?


Okay, here are some relatively messy thoughts, but hopefully some of it will be helpful. You can create a list of the digits in a number n with

seq(mod(floor(n/10^k),10),k,0,floor(log(n)))->digitList 

(the ones digit will be the first item in the list, ...)

Now, having a list of the digits, you can sort the list using

SortA digitList 

Construct a list of the differences between successive terms of digitList (where there will be 0s for duplicated digits):

∆List(digitList)->deltaList 

Now, you can do something like looping over deltaList and whenever you find a zero, check the corresponding location in digitList to see which digit is repeated.

Alternately, you could step through the sorted digitList, tracking the previous entry, and find duplicates that way.

  • 0
    @Issac: Thanks for your quick reply. However, I tried the {}, it did not work.2011-02-04
  • 0
    @Chan: Could you be more specific about what exactly you tried? (For instance, posting your code might help.) It also might be helpful to post what you're trying to achieve, as there may be some other way to get to your end goal.2011-02-04
  • 0
    @Issac: Thanks, see my update.2011-02-04
  • 0
    @Issac: I checked it again, it worked. But how can we do assignment for array. Let's say I want to set a[i] = 1. I did 1->a[i], but TI-89 said "syntax error". Could you help? Thanks in advance.2011-02-04
  • 0
    @Chan: That's strange—that kind of assignment works on my calculator. I've added some other thoughts about the problem as a whole, though I'm not sure if they're quite what you're looking for.2011-02-04
  • 0
    @Issac: Thanks for your solution. If I still want to use the array method above, then how could I solve it?2011-02-04
  • 0
    @Chan: I'm not sure. You might check to make sure you're running the most current OS for your model of calculator (is it an original TI-89 or a TI-89 Titanium?), since it looks like the code should work as written, on my calculator.2011-02-04
  • 0
    @Chan: OHH! I think the problem is that you're working with your list as if its index is zero-based, but it's one-based, so your program probably is choking on a digit 0. Either shift your references up by 1 or check if the digit is zero and replace it with 10 for indexing the list.2011-02-04
1

I don't know about TI-89 but as for TI-83+,84, they have Lists stored in L1, L2, etc that can be written to by {1,2,3,4}->L1. You can find L1 as 2nd 1, 2nd 2, 2nd 3, etc on the older models. I can't say exactly for the 89.

You can also do things like seq(Y1,X,0,4,.2)->L1 to quickly evaluate sequences and store in Lists.

  • 0
    On the 83/84, lists had to be in special L-variables (with a small-caps L), and L1-L6 were the most-often used, but you could name a list L-anything, pretty much. (I'm pretty sure this doesn't apply to the 89, but as I don't have one at hand to check...)2011-02-04
  • 1
    Confirmed: on the 89 (and similar), lists can be stored in arbitrarily-named variables.2011-02-04