Several mechanisms are available for saving and retrieving previously evaluated expressions. The simplest of these refers to the last algebraic expression simplified. When an assignment of an algebraic expression is made, or an expression is evaluated at the top level, (i.e., not inside a compound statement or procedure) the results of the evaluation are automatically saved in a variable WS that we shall refer to as the workspace. (More precisely, the expression is assigned to the variable WS that is then available for further manipulation.)
If we evaluate the expression (x+y)^2 at the top level and next wish to differentiate it with respect to Y, we can simply say
to get the desired answer.
If the user wishes to assign the workspace to a variable or expression for later use, the SAVEASstatement can be used. It has the syntax
For example, after the differentiation in the last example, the workspace holds the expression 2*x+2*y. If we wish to assign this to the variable Z we can now say
If the user wishes to save the expression in a form that allows him to use some of its variables as arbitrary parameters, the FOR ALL command can be used.
with the above expression would mean that h(z) evaluates to 2*Y+2*Z.
A further method for referencing more than the last expression is described in chapter 13 on interactive use of REDUCE.