Next: , Previous: , Up: Internal Routines   [Contents][Index]


15.5.77 calculator

calculator

Enters calculator mode. In calculator mode, LUX acts like a regular calculator: it has a current numerical scalar or array, or string value, (stored in variable $) which is modified by calculator commands, and which value is displayed after each command has been completed. Calculator mode can only be entered from the main execution level (i.e., not from within a function or subroutine), and no statements other than assignments and return can be executed.

Each newline ends a command. The result of each command replaces the current value. The following commands are supported: a numerical value; a LUX expression; a binary operator followed by an expression (the current value is taken for the first operand); the name of a single-argument function (the current value is taken for the operand); an equal sign followed by an expression; or the return command, which exits calculator mode.

Not all LUX expressions are supported. If the command is a single name, then it is taken to be the name of a single-argument function rather than the name of a variable (forming an expression). If you wish to assign the value of a variable to the current value, then prepend an equal sign. If you wish to evaluate a multi-argument function, then use $ if you want the current value for one or more of its arguments.

See also: Running