1

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.

  1. Have I correctly stated the syntax of this behavior?
  2. What are some possible use cases for this behavior?
  3. Where can I find official documentation of this behavior?

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.

Community
  • 1
  • 1
ankh-morpork
  • 1,732
  • 1
  • 19
  • 28

2 Answers2

1

Glad to answer a question of yours :)

  1. Pretty much. The list variables are most closely related in this behavior to graphing variables - function, polar, sequential, etc. in their ability to store the string. This makes it useful wherever self-modifying code can be applied.
  2. Basically, there are two main uses - self-modifying code and optimization. You're referring mainly to the use as optimization, where you store a lengthy formula into a variable for quick reference. Lists must return a list when called, so that's why your first example "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.
  3. I don't know anyplace where this is officially documented, since unfortunately I don't have the manual to reference. If you have any additional questions, I'd be happy to answer them for you.
Timtech
  • 1,224
  • 2
  • 19
  • 30
  • Great Answer! I dug up [this 827 page manual](http://ef.engr.utk.edu/ef152-2014-08/ti/ti83p-manual.pdf) after some Googling. It's rather lengthy, So I'll post the section relevant to my question in an answer. – ankh-morpork Mar 08 '15 at 22:16
1

In response to third question listed in the original post,

Where can I find official documentation of this behavior?

A PDF of a 827 page TI-83 manual is available online from University of Tennessee's College of Engineering. This manual contains documentations of the vast majority of TI-Basic features, including the one described in the original post.

The section of the manual relevant to the question starts on page 296 and continues until page 299.

Attaching Formulas to List Names

Attaching a Formula to a List Name

You can attach a formula to a list name so that each list element is a result of the formula. When executed, the attached formula must resolve to a list.

When anything in the attached formula changes, the list to which the formula is attached is updated automatically.

  • When you edit an element of a list that is referenced in the formula, the corresponding element in the list to which the formula is attached is updated.
  • When you edit the formula itself, all elements in the list to which the formula is attached are updated.

For example, the first screen below shows that elements are stored to L₃, and the formula L₃+10 is attached to the list name ʟADD10 The quotation marks designate the formula to be attached to ʟADD10. Each element of ʟADD10 is the sum of an element in L₃ and 10.

enter image description here

The next screen shows another list, L₄. The elements of L₄ are the sum of the same formula that is attached to L₃. However, quotation marks are not entered, so the formula is not attached to L₄.

On the next line, ⁻6→L₃(1):L₃ changes the first element of L₃ to ⁻6, and then redisplays L₃.

enter image description here

The last screen shows that editing L₃ updated ʟAdd10, but did not change L₄. This is because the formula L₃+10 is attached to ʟADD10, but it is not attached to l4

enter image description here

The formatting of the manual did not agree with StackOverflow so, I had to take some liberties in reformatting it for this answer.

ankh-morpork
  • 1,732
  • 1
  • 19
  • 28
  • Nice find! Since I couldn't find this information on wikidot I'll definitely read through some more of the manual. – Timtech Mar 09 '15 at 00:01