2

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}

AstroCB
  • 12,337
  • 20
  • 57
  • 73
Adam Staples
  • 396
  • 2
  • 7
  • 19
  • Any clarifications please ask me. I'm here to answer any questions, clarify, work through this together, etc. I know there has to be a way to iterate through a set of lists like I am trying because in the calculator there is such a notion of a '5th' string (if you click stat edit you'll see a number in the top right corner of each list o matter the name of the list). In the ti-84 you can have up to 999 elements per list and I think even 999 lists (you can correct me if I'm wrong). – Adam Staples Oct 14 '14 at 02:24

3 Answers3

3

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.

Vaelus
  • 1,065
  • 10
  • 27
  • I just tested the code and it's faster than I though assuming you don't have lists with indexes with more than a couple digits. – Vaelus May 23 '15 at 22:48
1

This is a pretty ugly (and possibly the only) method, but it is possible to do this by running a bunch of If commands.

For example,

Disp ʟL1
If K≥2
    Disp ʟL2
If K≥3
    Disp ʟL3
If K≥4
    Disp ʟL4
If K≥5
    Disp ʟL5

So on and so forth.


EDIT: I don't know if you still need an answer to this question, but I found a way to do exactly what you want. It's still very messy, though.

  1. Convert your number to a string, like Str0 (You can choose from a couple ways: link1 link2).

  2. Concatenate that number with the list name. For example, "ʟL" + Str0 → Str0.

  3. Evaluate the string with expr(.

As I said, this is very much ugly, and all those number-to-string conversions can't be too efficient, so you're probably better off copy-pasting a bunch of If statements for each condition.

Alternatively, you can compress all the lists you're using into a single big list, and have the start positions of each list stored in another list. Then you can extract any sublist you want from the big compress list with the seq( command.

user3932000
  • 671
  • 8
  • 24
0

There's no way to do that in TI-Basic. Just as there's no way to go from a string "X" to the contents of the variable X, there's no way to go from a number ot a list with that number in its name.

UPDATE: It turns out you can use expr("X") to get the value of X. And you can do that same with lists.

But alternatively, if you want to store a 2-dimensional array of data, TI-Basic does have matrices, although they are somewhat restricted compared to lists (in particular, you cannot create named matrices). If you need some data structure more complex than that, you may have reached the limits of this language.

Simon East
  • 55,742
  • 17
  • 139
  • 133