EVAL


Synopsis


Evaluate an object, recursively

Stack Diagram


Input Stack Output Stack
O see list under Description
Level 1 Level n Level 1

Legend

Type Operator
Parallel list processing Yes, but specific group is determined by the object being evaluated
Affected by flags -70 Global autosimplification rules
-71 Application of Group 1 autosimplification rules
-72 Application of Group 2 autosimplification rules
-73 Application of Group 3 autosimplification rules
-74 Application of Group 4 autosimplification rules
-75 Application of Group 5 autosimplification rules
-76 Application of Group 6 autosimplification rules
-77 Application of Group 7 autosimplification rules
-78 Application of Group 8 autosimplification rules
-103 Complex results

Description


The EVAL command evaluates the object on the top level of the stack. Evaluation occurs recursively.

The effect of the evaluation and the resulting output depends on the type of object being evaluated, as summarized by the following list.

  • Local Name: EVAL recalls the content of the variable.
  • Global Name: EVAL calls the content of a variable:
    1. a Name is EVALuated;
    2. a Program is EVALuated;
    3. a Directory becomes the current directory;
    4. other objects which are not lists are put on the stack.
  • Program: EVAL enters each object in the program:
    1. an unquoted Name is EVALuated;
    2. a Keyword is XEQted;
    3. other objects which are not lists are put on the stack.
  • Symbolic expression: EVAL enters each object in the expression:
    1. a Name is EVALuated;
    2. a Keyword is XEQted;
    3. other objects which are not lists are put on the stack.
  • Other objects: if they are not lists EVAL puts them on the stack.
  • List: EVAL enters each object in the list:
    1. any object is EVALuated according above mentioned rules.

As a final step, EVAL will perform numerical simplification according to the status of flags from -70 to -78.

Compatibility


This command is only partially compatible with userRPL.

In particular:

  • In userRPL, if the argument is a list EVAL enters any object in the list, then:
    1. a Name is EVALuated;
    2. a Program is EVALuated;
    3. a Keyword is XEQted;
    4. other objects are put on the stack.

while in newRPL, parallel list processing is performed.

Usage


If the following commands are executed

2:                          6.28
1:                       'TWOPI'
……………………………………………………………………………………
STO
2:                   « TWOPI * »
1:                      'CIRCUM'
……………………………………………………………………………………
STO

then the command

2:                             2
1:                      'CIRCUM'
……………………………………………………………………………………
EVAL

will perform the following steps:

  1. CIRCUM (a global name) is EVALuated;
  2. « TWOPI * » (a program) is EVALuated;
  3. TWOPI, the first object (a global name) in the program is EVALuated;
  4. 6.28 (a real number) is put on the stack;
  5. *, the second object (a keyword) in the program is XEQted.

Resulting in

1:                         12.56
……………………………………………………………………………………

The command

1:                    { '16' √ }
……………………………………………………………………………………
EVAL

will perform the following steps:

  1. '16' (a symbolic expression) is EVALuated;
  2. 16 (a real number) is put on the stack;
  3. (a keyword) is XEQted.

Resulting in

1:                        { 4. }
……………………………………………………………………………………

Related Commands


Overloadable operators 26 3 NEW

Operator Short Description
Evaluation operators:
EVAL1 Evaluate one level NEW
EVAL Evaluate full depth
XEQ Execute NEW
→NUM Compute numeric result
Test operators:
== Equality test
Not equal test
< Less than test
Less than or equal test
> Greater than test
Greater than or equal test
CMP Comparison test (<0 if A<B, 0 if A==B, >0 if A>B) NEW
SAME Comparison test, true if objects are the same
ISTRUE True test NEW
Logical operators:
AND Logical AND
OR Logical OR
XOR Logical XOR
NOT Logical NOT
Mathematic operators:
+ Addition
- Subtraction
* Multiplication
/ Division
^ Power
XROOT Root
INV Inverse
NEG Negate/change sign
ABS Magnitude or absolute value
  • manual/chapter6/operators/cmd_ovr_eval.txt
  • Last modified: 2019/11/17 08:23
  • by jojo1973