SETQ _ _ _ _ _ _ _ _ _ _ _ _ operator
The setq operator is an infix or prefix binary assignment operator. It is identical to :=.
setq(<restricted\_expression>,<expression>) or
<restricted\_expression> setq <expression>
<restricted expression> is ordinarily a single identifier, though simple expressions may be used (see Comments below). <expression> can be any valid REDUCE expression. If <expression> is a matrix identifier, then <restricted\_expression> can be a matrix identifier (redimensioned if necessary), which has each element set to the corresponding elements of the identifier on the right-hand side.
setq(b,6); B := 6 c setq sin(x); C := SIN(X) w + setq(c,x+3) + z; W + X + Z + 3 c; X + 3 setq(a1 + a2,25); A1 + A2 := 25 a1; - (A2 - 25)
Embedding a setq statement in an expression has the side effect of making the assignment, as shown in the third example above.
Assignments are generally done for identifiers, but may be done for simple expressions as well, subject to the following remarks:
_ _ _ (i) If the left-hand side is an identifier, an operator, or a power, the rule is added to the rule table.
_ _ _ (ii) If the operators - + / appear on the left-hand side, all but the first term of the expression is moved to the right-hand side.
_ _ _ (iii) If the operator * appears on the left-hand side, any constant terms are moved to the right-hand side, but the symbolic factors remain.
Be careful not to make a recursive setq assignment that is not controlled inside a loop statement. The process of resubstitution continues until you get a stack overflow message. setq can be used to attach functionality to operators, as the := does.