The → Command

Command Summary

Stores a value to a variable.

Command Syntax

valuevariable

Menu Location

Press the STO> key to insert →.

Calculator Compatibility

This command works on all calculators.

Token Size

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)
           Done

As 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

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.