TI-BASIC: Indexing to Prompt or Input command

566 views Asked by At

I have a TI-84 Plus, and I am creating a program to calculate the magnitude of an n-dimensional vector. I have included my code and its output below.

Program Editor:

PROGRAM:NTHDMAG
Disp "HOW MANY DIMENSIONS?"
Prompt N
{X,Y,Z,T,A,B,C,D,E,F,G,H,I,J,L,M,P,U,V,W}->L1
For(K,1,N,1)
L1(K)->Q
Prompt Q
End

Output Display:

pgrmNTHDMAG
HOW MANY DIMENSIONS?
N=?3
Q=?1
Q=?2
Q=?3
Done

I want the Q's to be replaced with each letter in L1, and indexing L1(K) in the Prompt command throws an error. The values for the L1 letters will be whatever the value of each component is (so here, for example, 1i + 2j + 3k).

I hope this is clear, but I am more than willing to clarify if it is not. Thank you for any help that you can provide!

1

There are 1 answers

7
harold On BEST ANSWER

This may be what you're trying to do,

Prompt N
0->dim(|LT
For(I,1,N
    Input sub("XYZTABCDEFGHIJLMPUVW",I,1)+"=?",X
    X->|LT(I)
End
Disp |LT
DelVar |LT

enter image description here

Input is used instead of Prompt, allowing us to choose the string. The string is built by taking a single-letter substring from "XYZTABCDEFGHIJLMPUVW" and then appending "=?" to it, making it look just like Prompt, of course this is easy to change. It's SourceCoder syntax so |L means that strange small ∟ for list names. Does not work if list T is archived, it could be made to work but IMO it should not, usually an archived list means the user wants to keep it.

It's much easier to let the user enter a list themselves though, for example

Input "Input List:",|LT
Disp |LT
DelVar |LT

This allows more convenient user input such as Rcl (of a whole list) and list operations, for example:

enter image description here

Or perhaps more typical:

enter image description here

But N is not explicit.

Leaving the result in Ans is probably useful. Implicitly printing by evaluating a value instead of a proper command on the last line gets rid of Done which isn't that useful, but it's something you can do.

Input "Input List:",|LT
sqrt(sum(|LT^^2
DelVar |LT
Ans

enter image description here