Genius Manual | ||
---|---|---|
<<< Previous | GEL Basics | Next >>> |
Syntax:
VariableName |
genius> e = 2.71828182846 |
To evaluate a variable by itself, just enter the name of the variable. This will return the value of the variable. You can use a variable anywhere you would normally use a number or string. In addition, variables are necessary when defining functions that take arguments (see the Section called Defining Functions).
Using Tab completion | |
---|---|
You can use Tab completion to get Genius to complete variable names for you. Try typing the first few letters of the name and pressing Tab. |
Variable names are case sensitive | |
---|---|
The names of variables are case sensitive. That means that variables named |
Syntax:
<identifier> = <value> <identifier> := <value> |
x = 3 x := 3 |
To assign to a variable, use the = or := operators. These operators set the value of the variable and return the number you set, so you can do things like
a = b = 5 |
The = and := operators can both be used to set variables. The difference between them is that the := operator always acts as an assignment operator, whereas the = operator may be interpreted as testing for equality when used in a context where a Boolean expression is expected.
For issues regarding the scope of variables, see the Section called Global Variables and Scope of Variables in the Chapter called Programming with GEL.
GEL has a number of built-in ‘variables’, such as
e
, pi
or GoldenRatio
. These are widely used constants with a preset value, and
they cannot be assigned new values.
There are a number of other built-in variables.
See the Section called Constants in the Chapter called List of GEL functions for a full list.
The Ans
and ans
variables can be used to get the result of the last expression. For example, if you had performed some calculation, to add 389 to the result you could do:
Ans+389 |
<<< Previous | Home | Next >>> |
GEL Basics | Up | Using Functions |