SqSub1(X) = (X-1)*(X-1)
$func SqSub1 sX = sZ; SqSub1 sX = <Mult <Sub sX 1> <Sub sX 1>>;
$func SqSub1 sX = sZ; $func Sq sY = sZ; SqSub1 sX = <Sq <Sub sX 1>>; Sq sY = <Mult sY sY>;
The function Sq serves the only purpose: it waits for the argument to be decremented by one, catches the result obtained, and continues the computation. It is obvious that superfluous auxiliary functions can make the program obscure and difficult to understand, for which reason Refal Plus enables us to introduce local variables for denoting intermediate values.
$func SqSub1 sX = sZ; SqSub1 sX = <Sub sX 1> :: sY, <Mult sY sY>;where <Sub sX 1> :: sY means that the variable sY is to be bound to the result of evaluating <Sub sX 1>. Then <Mult sY sY> is evaluated, and the result obtained is considered to be the result of evaluating the whole right hand side of the sentence. It should be noted that the value of sY is used while evaluating <Mult sY sY>.