Search code examples
arraysti-basic

Printing out a set of lists in the ti-84 ti-basic


I want to be able to print out L1 up to Lk (lists in the ti-84) for some arbitrary number k.

Lists in ti-basic are essentially one-dimensional arrays used to store a real or complex number into each of their elements.

Below I made my own lists named L1, ... L3 (not built in, in reality can be accessed and printed by typing LL1, ... LL3)

I will show you some of what I tried, etc.

let L5 = {5,5,5}

If I try the following code snippet:

PROGRAM: ITRTLST
:ClrHome
:Disp LL1
:For(J,1,3
:Disp J
:Disp LL5
:End

This code outputs:

1

{5,5,5}

2

{5,5,5}

3

{5,5,5}

Note the first 'L' in LL5 is a token (accessible by pressing [2nd]+[LIST(STAT)] OPS B:)

However if I try the following code snippet:

PROGRAM: ITRTLST
:ClrHome
:Disp LL1
:For(k,1,3
:Disp J
:Disp LLk
:End

I get ERR:UNDEFINED

This is because it thinks of 'LLK' as a list name rather than LL1, LL2, LL3

We can see this if I let LLK = {1,2,3} then the above code outputs

1

{1,2,3}

2

{1,2,3}

3

{1,2,3}


Solution

  • This can be done but it is a pain, and will probably be very slow.

    Try this code, with [Max] replaced with a number:

    :ClrHome
    :For(I,1,[Max])
    :"Convert I into a string, this is slow
    :I/10→D
    :sub("0123456789",10*fPart(D)+1,1)→Str1
    :int(D)→D
    :While D>0
    :D/10→D
    :sub("0123456789",10*fPart(D)+1,1)+Str1→Str1
    :int(D)→D
    :End
    :"Display the I'th list
    :Disp expr("ʟL" + Str1)
    :End
    

    Note that the lines starting with " are just comments and can be removed.