I recently became aware of an odd behavior of TI-Basic that allows the programmer to store a formula into a list variable. I've become quite familiar with TI-Basic over the years and have examined samples of code from sources such as TI-Basic Developer Forum, This StackOverflow tag and a Subreddit devoted to TI-Basic without finding anything other than acknowledgement of its existence .
The syntax to create this behavior is simple:
<String>→<List>
where <String>
represents any string , literal or variable. Experimentation has shown that this String must evaluate to a list. <List>
represents a list variable. Using a list literal will result in ERR:SYNTAX
.
To help with understanding what I am describing, here are some examples using actual code:
"X+2→L₁
"2L₁→L₂
Both example will run initially; however, if I try to access L₁
in the first example, I get ERR:DATA TYPE
. Accessing L₂
will return two times the current value of L₁
.
As this question has so far been a description of this behavior without a direct question, I will conclude by enumeration some specific questions that responses could answer.
These are just recommendations for what an answer could include. I will be happy to accept a well rounded and general analysis of this behavior.
Glad to answer a question of yours :)
"X+2→L₁
fails but "2L₁→L₂
successfully returns a list. For example, L1 can be used to store any equation that returns a list. If you wanted to get a list of 10 non-repeating numbers from 1-10, you would use randIntNoRep(1,10)
, 7 bytes (or 6 when unclosed), wherever you needed it. However, doing "randIntNoRep(1,10)->L1
allows you to call L1 anytime for a fresh call of the 10 random numbers. Note that when not in string format (e.g. randIntNoRep(1,10)->L1
), it will work, but each call to L1 will return the same list of numbers, since it is statically stored. Additionally, if the equation doesn't return a list by default, you can always add a list bracket at the beginning, but since there is only one element it would be much smarter to use a function or sequence variable (my personal favorite is u
). Another specific use of this functionality is in the Number or String routine, for detecting whether Ans is a number or a string.