|
We're glad you came by, but you might find what you're looking for elsewhere. TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it. Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope. |
Stores a value to a variable.
value→variable
Menu Location
Press the STO> key to insert →.
This command works on all calculators.
1 byte
The → operator assigns a value to a variable.
Initially, a variable such as 'x', 'lastname', or 'cube' is undefined. When used in an expression, they will be treated as unknowns: 3*x-x may be simplified to 2*x, but will otherwise be left alone.
Once a value is assigned to a variable, that value will be substituted for the variable every time you use it. For example, you might store 5→x. Now, if you write 3*x-x, the answer won't be 2*x, but 10.
Any kind of value — a simple number, an expression, a string, list, or matrix, or even a function can be stored to a variable with →. The following are all valid:
:5→x
5
:"Alighieri"→lastname
"Alighieri"
:n^3→cube(n)
DoneAs a special case, you can even store to a single element of a list or matrix. For example:
:{1,2,3,4,5}→list
{1 2 3 4 5}
:99→list[3]
99
:list
{1 2 99 4 5}Advanced Uses
Using the # (indirection) operator, you can store a value to a variable given its name, in a string.
Optimization
There are alternatives to → such as Define or CopyVar; they have their uses in special situations, but → is better (smaller and easier to understand) in other cases.
Error Conditions
190 - Circular definition happens when an undefined variable is given a value in terms of itself (e.g. x+1→x).
Related Commands
- # (indirection)
- Define
- DelVar