1

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!

  • `Input` allows custom strings to be displayed, but is this really what you need in the first place? User could enter a list themselves with the usual `{A,B,C` syntax (this also enables using `Rcl` with an existing list which may be convenient), of course then `N` is not predetermined – harold Sep 13 '17 at 12:26
  • @harold I could have the user input a string, but that's less user friendly and I don't want that. I mean I can if I have to, but I would prefer to present one variable at a time. – ProgrammingEnthusiast Sep 13 '17 at 12:44
  • `Input` allows a custom string to be *displayed* (and read as input too but that's not the point). That's what you're trying to do, right? Replace "Q=?" by a custom string? – harold Sep 13 '17 at 12:48
  • @harold Yes that is correct and that is what I'm not sure how to do. – ProgrammingEnthusiast Sep 13 '17 at 13:02

1 Answers1

1

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

harold
  • 61,398
  • 6
  • 86
  • 164
  • Thank you very much! I just have one follow up question: since the list is declared inside the for loop, will I be able to call the variables created by the user elsewhere in my code? – ProgrammingEnthusiast Sep 13 '17 at 14:00
  • @ProgrammingEnthusiast yes, variables are global and not even declared as such, it is `0->dim(|LT` that would create the list if it did not exist – harold Sep 13 '17 at 14:03
  • @ProgrammingEnthusiast though if you meant variable X, Y, Z etc.. it does not work like that, the result is in a list here. There is no reasonable way to assign to a "variable variable" (as in most languages for that matter). – harold Sep 13 '17 at 14:09
  • Also, how do you get the symbols "sub" and "|" on the calculator? – ProgrammingEnthusiast Sep 13 '17 at 14:10
  • @ProgrammingEnthusiast `sub(` is in the catalog, go to T and press up twice. `|L` is the small L for list names, go to LIST, OPS, press up. – harold Sep 13 '17 at 14:16
  • Also, just for my own curiosity, how did you get the calculator screens into the answer? It's cool! – ProgrammingEnthusiast Sep 13 '17 at 14:29
  • @ProgrammingEnthusiast I used [SourceCoder](https://www.cemetech.net/sc/), it has an emulator that can record the screen like this – harold Sep 13 '17 at 14:37