Artifact 5ce795542e6ee8bfd06154e34e78460211c48d95709d018fc5013532e9e8e566:
- Executable file
r37/lisp/csl/html/r37_0065.html
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 2281) [annotate] [blame] [check-ins using] [more...]
<A NAME=SETQ> <TITLE>SETQ</TITLE></A> <b><a href=r37_idx.html>INDEX</a></b><p><p> <B>SETQ</B> _ _ _ _ _ _ _ _ _ _ _ _ <B>operator</B><P> <P> <P> <P> The <em>setq</em> operator is an infix or prefix binary assignment operator. It is identical to <em>:=</em>. <P> <H3> syntax: </H3> <P> <P> <em>setq</em>(<restricted\_expression>,<expression>) or <P> <P> <restricted\_expression> <em>setq</em> <expression> <P> <P> <P> <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 <A HREF=r37_0345.html>matrix</A> 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. <P> <P> <P> <H3> examples: </H3> <P><PRE><TT> 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) </TT></PRE><P>Embedding a <em>setq</em> statement in an expression has the side effect of making the assignment, as shown in the third example above. <P> <P> Assignments are generally done for identifiers, but may be done for simple expressions as well, subject to the following remarks: <P> <P> _ _ _ (i) If the left-hand side is an identifier, an operator, or a power, the rule is added to the rule table. <P> <P> _ _ _ (ii) If the operators <em>- + /</em> appear on the left-hand side, all but the first term of the expression is moved to the right-hand side. <P> <P> _ _ _ (iii) If the operator <em>*</em> appears on the left-hand side, any constant terms are moved to the right-hand side, but the symbolic factors remain. <P> <P> Be careful not to make a recursive <em>setq</em> assignment that is not controlled inside a loop statement. The process of resubstitution continues until you get a stack overflow message. <em>setq</em> can be used to attach functionality to operators, as the <em>:=</em> does. <P> <P> <P>