File r38/lisp/csl/r38.doc/r38_0001.html artifact dbe59f33d1 part of check-in c70d02b470



<a name=r38_0001>

<title>IDENTIFIER</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>IDENTIFIER</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>type</b><P>
<P>
 
Identifiers in REDUCE consist of one or more alphanumeric characters, of 
which the first must be alphabetical. The maximum number of characters 
allowed is system dependent, but is usually over 100. However, printing 
is simplified if they are kept under 25 characters. 
<P>
<P>
You can also use special characters in your identifiers, but each must be 
preceded by an exclamation point <em>!</em> as an escape character. Useful 
special characters are <em> # $ % ^ &amp; * - + = ? &lt; &gt; ~ | / !</em> and 
the space. Note that the use of the exclamation point as a special 
character requires a second exclamation point as an escape character. 
The underscore <em>_</em> is special in this regard. It must be preceded 
by an escape character in the first position in an identifier, but is 
treated like a normal letter within an identifier. 
<P>
<P>
Other characters, such as <em>( ) # ; ` ' &quot;</em> can also be used if 
preceded by a <em>!</em>, but as they have special meanings to the Lisp 
reader it is best to avoid them to avoid confusion. 
<P>
<P>
Many system identifiers have * before or after their names, or - between 
words. If you accidentally pick one of these names for your own identifier, 
it could have disastrous effects. For this reason it is wise not to include 
* or - anywhere in your identifiers. 
<P>
<P>
You will notice that REDUCE does not use the escape characters when it prints 
identifiers containing special characters; however, you still must use them 
when you refer to these identifiers. Be careful when editing statements 
containing escaped special characters to treat the character and its escape 
as an inseparable pair. 
<P>
<P>
Identifiers are used for variable names, labels for <em>go to</em> statements, 
and names of arrays, matrices, operators, and procedures. Once an identifier is 

used as a matrix, array, scalar or operator identifier, it may not be used 
again as a matrix, array or operator. An operator or array identifier may 
later be used as a scalar without problems, but a matrix identifier cannot be 
used as a scalar. All procedures are entered into the system as operators, so 
the name of a procedure may not be used as a matrix, array, or operator 
identifier either. 
 <P>
<P>

<a name=r38_0002>

<title>KERNEL</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>KERNEL</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>type</b><P>
<P>
 
A <em>kernel</em> is a form that cannot be modified further by the REDUCE 
canonical simplifier. Scalar variables are always kernels. The 
other important class of kernels are operators with their arguments. 
Some examples should help clarify this concept: 
<P>
<P>
<p><pre><tt>
        Expression                     Kernel?

          x                              Yes
          varname                        Yes
          cos(a)                         Yes
          log(sin(x**2))                 Yes
          a*b                            No
          (x+y)**4                       No
          matrix-identifier              No
</tt></pre><p>Many REDUCE operators expect kernels among their arguments. Error 
messages 
result from attempts to use non-kernel expressions for these arguments. 
 <P>
<P>

<a name=r38_0003>

<title>STRING</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>STRING</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>type</b><P>
<P>
 
A <em>string</em> is any collection of characters enclosed in double quotation 
marks (<em>&quot;</em>). It may be used as an argument for a variety of commands
 
and operators, such as <em>in</em>, <em>rederr</em> and <em>write</em>. 
 <P> <H3> 
examples: </H3>
<p><pre><tt>
write &quot;this is a string&quot;; 

  this is a string 


write a, &quot; &quot;, b, &quot; &quot;,c,&quot;!&quot;; 

  A B C!

</tt></pre><p><P>
<P>

<a name=r38_0004>

<title>Concepts</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>
<b>Concepts</b><menu>
<li><a href=r38_0001.html#r38_0001>IDENTIFIER type</a><P>
<li><a href=r38_0001.html#r38_0002>KERNEL type</a><P>
<li><a href=r38_0001.html#r38_0003>STRING type</a><P>
</menu>
<a name=r38_0005>

<title>assumptions</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>ASSUMPTIONS</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>variable</b><P>
<P>
 
 <P>
<P>
After solving a linear or polynomial equation system 
with parameters, the variable <em>assumptions</em> contains a list 
of side relations for the parameters. The solution is valid only 
as long as none of these expression is zero. 
 <P> <H3> 
examples: </H3>
<p><pre><tt>
solve({a*x-b*y+x,y-c},{x,y});

       b*c
  {{x=-----,y=c}} 
      a + 1


assumptions; 

  {a + 1}

</tt></pre><p><P>
<P>

<a name=r38_0006>

<title>CARD_NO</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>CARD\_NO</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>variable</b><P>
<P>
 
 <P>
<P>
<em>card_no</em>sets the total number of cards allowed in a Fortran 
output statement when <em>fort</em> is on. Default is 20. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
on fort; 

card_no := 4; 

  CARD_NO=4. 


z := (x + y)**15; 

        ANS1=5005.*X**6*Y**9+3003.*X**5*Y**10+1365.*X**4*Y**
       . 11+455.*X**3*Y**12+105.*X**2*Y**13+15.*X*Y**14+Y**15
        Z=X**15+15.*X**14*Y+105.*X**13*Y**2+455.*X**12*Y**3+ 
       . 1365.*X**11*Y**4+3003.*X**10*Y**5+5005.*X**9*Y**6+
       . 6435.*X**8*Y**7+6435.*X**7*Y**8+ANS1

</tt></pre><p>Twenty total cards means 19 continuation cards. You may set it for
 more 
if your Fortran system allows more. Expressions are broken apart in a 
Fortran-compatible way if they extend for more than <em>card_no</em> 
continuation cards. 
<P>
<P>
<P>

<a name=r38_0007>

<title>E</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>E</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>constant</b><P>
<P>
 
The constant <em>e</em> is reserved for use as the base of the natural 
logarithm. Its value is approximately 2.71828284590, which REDUCE gives 
to the current decimal precision when the switch 
<a href=r38_0300.html#r38_0330>rounded</a> is on. 
<P>
<P>
<em>e</em>may be used as an iterative variable in a 
<a href=r38_0001.html#r38_0047>for</a> statement, 
or as a local variable or a 
<a href=r38_0050.html#r38_0055>procedure</a>. If <em>e</em> is defined 
as a local 
variable inside the procedure, the normal definition as the base of the 
natural logarithm would be suspended inside the procedure. 
<P>
<P>
<P>

<a name=r38_0008>

<title>EVAL_MODE</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>EVAL\_MODE</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>variable</b><P>
<P>
 
 <P>
<P>
The system variable <em>eval_mode</em> contains the current mode, either 

<a href=r38_0150.html#r38_0186>algebraic</a> or 
<a href=r38_0200.html#r38_0221>symbolic</a>. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
EVAL_MODE; 

  ALGEBRAIC

</tt></pre><p>Some commands do not behave the same way in algebraic and symbolic
 modes. 
<P>
<P>
<P>

<a name=r38_0009>

<title>FORT_WIDTH</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>FORT\_WIDTH</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>variable</b><P>
<P>
 
 <P>
<P>
The <em>fort_width</em> variable sets the number of characters in a line of 
Fortran-compatible output produced when the 
<a href=r38_0250.html#r38_0289>fort</a> switch is on. 
Default is 70. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
fort_width := 30; 

  FORT_WIDTH := 30  


on fort; 

df(sin(x**3*y),x); 

        ANS=3.*COS(X
       . **3*Y)*X**2*
       . Y

</tt></pre><p><em>fort_width</em>includes the usually blank characters at the be
ginning 
of the card. As you may notice above, it is conservative and makes the 
lines even shorter than it was told. 
<P>
<P>
<P>

<a name=r38_0010>

<title>HIGH_POW</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>HIGH\_POW</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>variable</b><P>
<P>
 
 <P>
<P>
The variable <em>high_pow</em> is set by 
<a href=r38_0100.html#r38_0141>coeff</a> to the highest power 
of the variable of interest in the given expression. You can access this 
variable for use in further computation or display. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
coeff((x+1)^5*(x*(y+3)^2)^2,x); 

  {0,
   0,
    4       3       2
   Y  + 12*Y  + 54*Y  + 108*Y + 81,
       4       3       2
   5*(Y  + 12*Y  + 54*Y  + 108*Y + 81),
        4       3       2
   10*(Y  + 12*Y  + 54*Y  + 108*Y + 81),
        4       3       2
   10*(Y  + 12*Y  + 54*Y  + 108*Y + 81),
       4       3       2
   5*(Y  + 12*Y  + 54*Y  + 108*Y + 81),
    4       3       2
   Y  + 12*Y  + 54*Y  + 108*Y + 81}


high_pow; 

  7

</tt></pre><p>
<a name=r38_0011>

<title>I</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>I</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>constant</b><P>
<P>
 
 <P>
<P>
REDUCE knows <em>i</em> is the square root of -1, 
 and that i^2 = -1. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
(a + b*i)*(c + d*i); 

  A*C + A*D*I + B*C*I - B*D 


i**2; 

  -1

</tt></pre><p><em>i</em>cannot be used as an identifier. It is all right to use 
<em>i</em> 
as an index variable in a <em>for</em> loop, or as a local (<em>scalar</em>) 
variable inside a <em>begin...end</em> block, but it loses its definition as 
the square root of -1 inside the block in that case. 
<P>
<P>
Only the simplest properties of i are known by REDUCE unless 
the switch 
<a href=r38_0250.html#r38_0274>complex</a> is turned on, which implements full c
omplex 
arithmetic in factoring, simplification, and functional values. 
<em>complex</em> is ordinarily off. 
<P>
<P>
<P>

<a name=r38_0012>

<title>INFINITY</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>INFINITY</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>constant</b><P>
<P>
 
The name <em>infinity</em> is used to represent the infinite positive number. 
However, at the present time, arithmetic in terms of this operator reflects 
finite arithmetic, rather than true operations on infinity. 
<P>
<P>

<a name=r38_0013>

<title>LOW_POW</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>LOW\_POW</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>variable</b><P>
<P>
 
 <P>
<P>
The variable <em>low_pow</em> is set by 
<a href=r38_0100.html#r38_0141>coeff</a> to the lowest power 
of the variable of interest in the given expression. You can access this 
variable for use in further computation or display. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
coeff((x+2*y)**6,y); 

    6
  {X ,
       5
   12*X ,
       4
   60*X ,
        3
   160*X ,
        2
   240*X ,
   192*X,
   64}


low_pow; 

  0 


coeff(x**2*(x*sin(y) + 1),x); 
			 


  {0,0,1,SIN(Y)} 


low_pow; 

  2

</tt></pre><p>
<a name=r38_0014>

<title>NIL</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>NIL</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>constant</b><P>
<P>
 
 <P>
<P>
<em>nil</em>represents the truth value false in symbolic mode, and is 
a synonym for 0 in algebraic mode. It cannot be used for any other 
purpose, even inside procedures or 
<a href=r38_0001.html#r38_0047>for</a> loops. 
<P>
<P>

<a name=r38_0015>

<title>PI</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>PI</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>constant</b><P>
<P>
 
The identifier <em>pi</em> is reserved for use as the circular constant. 
Its value is given by 3.14159265358..., which REDUCE gives to the current 
decimal precision when REDUCE is in a floating-point mode. 
<P>
<P>
<em>pi</em>may be used as a looping variable in a 
<a href=r38_0001.html#r38_0047>for</a> statement, 
or as a local variable in a 
<a href=r38_0050.html#r38_0055>procedure</a>. Its value in such cases 
will be taken from the local environment. 
<P>
<P>
<P>

<a name=r38_0016>

<title>requirements</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>REQUIREMENTS</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>variable</b><P>
<P>
 
 <P>
<P>
After an attempt to solve an inconsistent equation system 
with parameters, the variable <em>requirements</em> contains a list 
of expressions. These expressions define a set of conditions implicitly 
equated with zero. Any solution to this system defines a setting for 
the parameters sufficient to make the original system consistent. 
 <P> <H3> 
examples: </H3>
<p><pre><tt>
solve({x-a,x-y,y-1},{x,y}); 

  {}


requirements;

  {a - 1}

</tt></pre><p><P>
<P>

<a name=r38_0017>

<title>ROOT_MULTIPLICITIES</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>ROOT\_MULTIPLICITIES</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>variable</b><P>
<P>
 
 <P>
<P>
The <em>root_multiplicities</em> variable is set to the list of the 
multiplicities of the roots of an equation by the 
<a href=r38_0150.html#r38_0179>solve</a> operator. 
<P>
<P>

<a href=r38_0150.html#r38_0179>solve</a>returns its solutions in a list. The mul
tiplicities of 
each solution are put in the corresponding locations of the list 
<em>root_multiplicities</em>. 
<P>
<P>
<P>

<a name=r38_0018>

<title>T</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>T</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>constant</b><P>
<P>
 
The constant <em>t</em> stands for the truth value true. It cannot be used 
as a scalar variable in a 
<a href=r38_0001.html#r38_0041>block</a>, as a looping variable in a 

<a href=r38_0001.html#r38_0047>for</a> statement or as an 
<a href=r38_0200.html#r38_0211>operator</a> name. 
<P>
<P>

<a name=r38_0019>

<title>Variables</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>
<b>Variables</b><menu>
<li><a href=r38_0001.html#r38_0005>assumptions variable</a><P>
<li><a href=r38_0001.html#r38_0006>CARD\_NO variable</a><P>
<li><a href=r38_0001.html#r38_0007>E constant</a><P>
<li><a href=r38_0001.html#r38_0008>EVAL\_MODE variable</a><P>
<li><a href=r38_0001.html#r38_0009>FORT\_WIDTH variable</a><P>
<li><a href=r38_0001.html#r38_0010>HIGH\_POW variable</a><P>
<li><a href=r38_0001.html#r38_0011>I constant</a><P>
<li><a href=r38_0001.html#r38_0012>INFINITY constant</a><P>
<li><a href=r38_0001.html#r38_0013>LOW\_POW variable</a><P>
<li><a href=r38_0001.html#r38_0014>NIL constant</a><P>
<li><a href=r38_0001.html#r38_0015>PI constant</a><P>
<li><a href=r38_0001.html#r38_0016>requirements variable</a><P>
<li><a href=r38_0001.html#r38_0017>ROOT\_MULTIPLICITIES variable</a><P>
<li><a href=r38_0001.html#r38_0018>T constant</a><P>
</menu>
<a name=r38_0020>

<title>semicolon</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>;</b> _ _ _ <b>SEMICOLON</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
The semicolon is a statement delimiter, indicating results are to be printed 
when used in interactive mode. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
(x+1)**2; 

   2
  X  + 2*X + 1 


df(x**2 + 1,x); 

  2*X

</tt></pre><p>Entering a <em>Return</em> without a semicolon or dollar sign resu
lts in a 
prompt on the following line. A semicolon or dollar sign can be 
added at this point to execute the statement. In interactive mode, a 
statement that is ended with a semicolon and <em>Return</em> has its results 
printed on the screen. 
<P>
<P>
Inside a group statement <em>&lt;&lt;</em>...<em>&gt;&gt;</em> 
or a <em>begin</em>...<em>end</em> block, a 
semicolon or dollar sign separates individual REDUCE statements. Since 
results are not printed from a block without a specific <em>return</em> 
statement, there is no difference between using the semicolon or dollar 
sign. In a group statement, the last value produced is the value 
returned by the group statement. Thus, if a semicolon or dollar sign is 
placed between the last statement and the ending brackets, the group 
statement returns the value 0 or nil, rather than the value of the 
last statement. 
<P>
<P>
<P>

<a name=r38_0021>

<title>dollar</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>$</b> _ _ _ <b>DOLLAR</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
The dollar sign is a statement delimiter, indicating results are not to be 
printed when used in interactive mode. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>

(x+1)**2$ </tt></pre><p>The workspace is set to x^2 + 2x + 1 
 but nothing shows on the screen<p><pre><tt>


ws; 

   2
  X   + 2*X + 1

</tt></pre><p> 
<P>
<P>
Entering a <em>Return</em> without a semicolon or dollar sign results in a 
prompt on the following line. A semicolon or dollar sign can 
be added at this point to execute the statement. In interactive mode, a 
statement that ends with a dollar sign <em>$</em> and a <em>Return</em> is 
executed, but the results not printed. 
<P>
<P>
Inside a 
<a href=r38_0001.html#r38_0038>group</a> statement <em>&lt;&lt;</em>...<em>&gt;
&gt;</em> 
or a <em>begin</em>...<em>end</em> 
<a href=r38_0001.html#r38_0041>block</a>, a 
semicolon or dollar sign separates individual REDUCE statements. Since 
results are not printed from a 
<a href=r38_0001.html#r38_0041>block</a> without a specific 

<a href=r38_0050.html#r38_0058>return</a><P>
<P>
statement, there is no difference between using the semicolon or dollar 
sign. 
<P>
<P>
In a group statement, the last value produced is the value returned by the 
group statement. Thus, if a semicolon or dollar sign is placed between the 
last statement and the ending brackets, the group statement returns the 
value 0 or nil, rather than the value of the last statement. 
<P>
<P>
<P>
<P>

<a name=r38_0022>

<title>percent</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>%</b> _ _ _ <b>PERCENT</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
The percent sign is used to precede comments; everything from a percent 
to the end of the line is ignored. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>

df(x**3 + y,x);% This is a comment key{Return} 


     2
  3*X  


int(3*x**2,x) %This is a comment; key{Return} 
</tt></pre><p>A prompt is given, waiting for the semicolon that was not 
detected in the comment<p><pre><tt></tt></pre><p> 
<P>
<P>
Statement delimiters <em>;</em> and <em>$</em> are not detected between a 
percent sign and the end of the line. 
<P>
<P>
<P>

<a name=r38_0023>

<title>dot</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>.</b> _ _ _ <b>DOT</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
 <P>
<P>
The . (dot) infix binary operator adds a new item to the beginning of an 
existing 
<a href=r38_0300.html#r38_0302>list</a>. In high energy physics expressions, 
it can also be used 
to represent the scalar product of two Lorentz four-vectors. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;item&gt; <em>.</em> &lt;list&gt; 
<P>
<P>
<P>
&lt;item&gt; can be any REDUCE scalar expression, including a list; 
&lt;list&gt; must be a 
<a href=r38_0300.html#r38_0302>list</a> to avoid producing an error message. 
The dot operator is right associative. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>

liss := a . {}; 

  LISS := {A} 


liss := b . liss; 

  LISS := {B,A} 


newliss := liss . liss; 

  NEWLISS := {{B,A},B,A} 


firstlis := a . b . {c}; 

  FIRSTLIS := {A,B,C} 


secondlis := x . y . {z}; 

  SECONDLIS := {X,Y,Z} 


for i := 1:3 sum part(firstlis,i)*part(secondlis,i);
 


  A*X + B*Y + C*Z

</tt></pre><p>
<a name=r38_0024>

<title>assign</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>:=</b> _ _ _ <b>ASSIGN</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
 <P>
<P>
The <em>:=</em> is the assignment operator, assigning the value on the right-han
d 
side to the identifier or other valid expression on the left-hand side. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;restricted\_expression&gt; <em>:=</em> &lt;expression&gt; 
<P>
<P>
<P>
&lt;restricted\_expression&gt; is ordinarily a single identifier, though simple 

expressions may be used (see Comments below). &lt;expression&gt; is any 
valid REDUCE expression. If &lt;expression&gt; is a 
<a href=r38_0300.html#r38_0345>matrix</a> 
identifier, then 
&lt;restricted\_expression&gt; 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>
a := x**2 + 1; 

        2
  A := X   + 1 


a; 

   2
  X  + 1 


first := second := third; 

  FIRST := SECOND := THIRD 


first; 

  THIRD 


second; 

  THIRD 


b := for i := 1:5 product i; 

  B := 120 


b; 

  120 


w + (c := x + 3) + z; 

  W + X + Z + 3 


c; 

  X + 3 


y + b := c; 

  Y + B := C 


y; 

  - (B - C)

</tt></pre><p>The assignment operator is right associative, as shown in the seco
nd and 
third examples. A string of such assignments has all but the last 
item set to the value of the last item. Embedding an assignment statement 
in another expression has the side effect of making the assignment, as well 
as causing the given replacement in the expression. 
<P>
<P>
Assignments of values to expressions rather than simple identifiers (such as in 

the last example above) can also be done, subject to the following remarks: 
<P>
<P>
 _ _ _ (i) 
If the left-hand side is an identifier, an operator, or a power, the 
substitution 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>
Assignment is valid for 
<a href=r38_0150.html#r38_0188>array</a> elements, but not for entire arrays. 
The assignment operator can also be used to attach functionality to operators. 
<P>
<P>
A recursive construction such as <em>a := a + b</em> is allowed, but when 
<em>a</em> is referenced again, the process of resubstitution continues 
until the expression stack overflows (you get an error message). 
Recursive assignments can be done safely inside controlled loop 
expressions, such as 
<a href=r38_0001.html#r38_0047>for</a>... or 
<a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em>. 
<P>
<P>
<P>
<P>

<a name=r38_0025>

<title>equalsign</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>=</b> _ _ _ <b>EQUALSIGN</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>=</em> operator is a prefix or infix equality comparison operator. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
<em>=</em>(&lt;expression&gt;<em>,</em>&lt;expression&gt;) 
 or 
 &lt;expression&gt; <em>=</em> &lt;expression&gt; 
<P>
<P>
<P>
&lt;expression&gt; can be any REDUCE scalar expression. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
a := 4; 

  A := 4 


if =(a,10) then write &quot;yes&quot; else write &quot;no&quot;;
 


  no 


b := c; 

  B := C 


if b = c then write &quot;yes&quot; else write &quot;no&quot;;
 


  yes 


on rounded; 

if 4.0 = 4 then write &quot;yes&quot; else write &quot;no&quot;;
 


  yes

</tt></pre><p>This logical equality operator can only be used inside a condition
al 
statement, such as 
<a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> 
or 
<a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em>. In other places the 
equal 
sign establishes an algebraic object of type 
<a href=r38_0001.html#r38_0045>equation</a>. 
<P>
<P>
<P>
<P>

<a name=r38_0026>

<title>replace</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>=></b> _ _ _ <b>REPLACE</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
<P>
<P>
The <em>=&gt;</em> operator is a binary operator used in 
<a href=r38_0050.html#r38_0060>rule</a> lists to 
denote replacements. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
operator f; 

let f(x) =&gt; x^2; 

f(x); 

   2
  x

</tt></pre><p>
<a name=r38_0027>

<title>plussign</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>+</b> _ _ _ <b>PLUSSIGN</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>+</em> operator is a prefix or infix n-ary addition operator. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; { <em>+</em>&lt;expression&gt;}+ 
<P>
<P>
or <em>+</em>(&lt;expression&gt; {,&lt;expression&gt;}+) 
<P>
<P>
<P>
&lt;expression&gt; may be any valid REDUCE expression. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
x**4 + 4*x**2 + 17*x + 1; 

   4      2
  X  + 4*X  + 17*X + 1 


14 + 15 + x; 

  X + 29 


+(1,2,3,4,5); 

  15

</tt></pre><p><em>+</em>is also valid as an addition operator for 
<a href=r38_0300.html#r38_0345>matrix</a> variables 
that are of the same dimensions and for 
<a href=r38_0001.html#r38_0045>equation</a>s. 
<P>
<P>
<P>

<a name=r38_0028>

<title>minussign</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>-</b> _ _ _ <b>MINUSSIGN</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>-</em> operator is a prefix or infix binary subtraction operator, as wel
l 
as the unary minus operator. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; <em>-</em> &lt;expression&gt; 
or <em>-</em>(&lt;expression&gt;,&lt;expression&gt;) 
<P>
<P>
<P>
&lt;expression&gt; may be any valid REDUCE expression. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
15 - 4; 

  11 


x*(-5); 

  - 5*X 


a - b - 15; 

  A - B - 15 


-(a,4); 

  A - 4

</tt></pre><p>The subtraction operator is left associative, so that a - b - c is
 equivalent 
to (a - b) - c, as shown in the third example. The subtraction operator is 
also valid with 
<a href=r38_0300.html#r38_0345>matrix</a> expressions of the correct dimensions 

and with 
<a href=r38_0001.html#r38_0045>equation</a>s. 
<P>
<P>
<P>

<a name=r38_0029>

<title>asterisk</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>*</b> _ _ _ <b>ASTERISK</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>*</em> operator is a prefix or infix n-ary multiplication operator. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; { <em>*</em> &lt;expression&gt;}+ 
<P>
<P>
or <em>*</em>(&lt;expression&gt; {,&lt;expression&gt;}+) 
<P>
<P>
<P>
&lt;expression&gt; may be any valid REDUCE expression. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
15*3; 

  45 


24*x*yvalue*2; 

  48*X*YVALUE 


*(6,x); 

  6*X 


on rounded; 

3*1.5*x*x*x; 

       3
  4.5*X  


off rounded; 

2x**2; 

     2
  2*X

</tt></pre><p>REDUCE assumes you are using an implicit multiplication operator w
hen an 
identifier is preceded by a number, as shown in the last line above. Since 
no valid identifiers can begin with numbers, there is no ambiguity in 
making this assumption. 
<P>
<P>
The multiplication operator is also valid with 
<a href=r38_0300.html#r38_0345>matrix</a> expressions 
of the 
proper dimensions: matrices A and B 
can be multiplied if 
A is n x m and B is 
m x p. Matrices and 
<a href=r38_0001.html#r38_0045>equation</a>s can also be 
multiplied by scalars: the 
result is as if each element was multiplied by the scalar. 
<P>
<P>
<P>

<a name=r38_0030>

<title>slash</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>/</b> _ _ _ <b>SLASH</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>/</em> operator is a prefix or infix binary division operator or 
prefix unary 
<a href=r38_0100.html#r38_0101>recip</a>rocal operator. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt;<em>/</em>&lt;expression&gt; or 
 <em>/</em>&lt;expression&gt; 
<P>
<P>
or <em>/</em>(&lt;expression&gt;,&lt;expression&gt;) 
<P>
<P>
<P>
&lt;expression&gt; may be any valid REDUCE expression. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
20/5; 

  4  


100/6; 

  50
  -- 
  3


16/2/x; 

  8
  - 
  X


/b; 

  1
  - 
  B


/(y,5); 

  Y
  - 
  5


on rounded; 

35/4; 

  8.75 


/20; 

  0.05

</tt></pre><p>The division operator is left associative, so that <em>a/b/c</em> 
is equivalent 
to <em>(a/b)/c</em>. The division operator is also valid with square 

<a href=r38_0300.html#r38_0345>matrix</a> expressions of the same dimensions: Wi
th A and 
B both n x n matrices and B 
invertible, A/B is 
given by A*B^-1. 
Division of a matrix by a scalar is defined, with the results being the 
division of each element of the matrix by the scalar. Division of a 
scalar by a matrix is defined if the matrix is invertible, and has the 
effect of multiplying the scalar by the inverse of the matrix. When 
<em>/</em> is used as a reciprocal operator for a matrix, the inverse of 
the matrix is returned if it exists. 
<P>
<P>
<P>

<a name=r38_0031>

<title>power</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>**</b> _ _ _ <b>POWER</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>**</em> operator is a prefix or infix binary exponentiation operator. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; <em>**</em>&lt;expression&gt; 
 or <em>**</em>(&lt;expression&gt;,&lt;expression&gt;) 
<P>
<P>
<P>
&lt;expression&gt; may be any valid REDUCE expression. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
x**15; 

   15
  X   


x**y**z; 

   Y*Z
  X    


x**(y**z); 

    Z
   Y
  X   


 **(y,4); 

   4
  Y  


on rounded; 

2**pi; 

  8.82497782708

</tt></pre><p>The exponentiation operator is left associative, so that <em>a**b*
*c</em> is 
equivalent to <em>(a**b)**c</em>, as shown in the second example. Note 
that this is not <em>a**(b**c)</em>, which would be right associative. 
<P>
<P>
When 
<a href=r38_0300.html#r38_0308>nat</a> is on (the default), REDUCE output produc
es raised 
exponents, as shown. The symbol <em>^</em>, which is the upper-case 6 on 
most keyboards, may be used in the place of <em>**</em>. 
<P>
<P>
A square 
<a href=r38_0300.html#r38_0345>matrix</a> may also be raised to positive and neg
ative powers 
with the exponentiation operator (negative powers require the matrix to be 
invertible). Scalar expressions and 
<a href=r38_0001.html#r38_0045>equation</a>s may be raised to 
fractional and floating-point powers. 
<P>
<P>
<P>

<a name=r38_0032>

<title>caret</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>^</b> _ _ _ <b>CARET</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>^</em> operator is a prefix or infix binary exponentiation operator. 
It is equivalent to 
<a href=r38_0001.html#r38_0031>power</a> or **. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; <em>^</em>&lt;expression&gt; 
 or <em>^</em>(&lt;expression&gt;,&lt;expression&gt;) 
<P>
<P>
<P>
&lt;expression&gt; may be any valid REDUCE expression. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
x^15; 

   15
  X   


x^y^z; 

   Y*Z
  X    


x^(y^z); 

    Z
   Y
  X   


^(y,4); 

   4
  Y  


on rounded; 

2^pi; 

  8.82497782708

</tt></pre><p>The exponentiation operator is left associative, so that <em>a^b^c
</em> is 
equivalent to <em>(a^b)^c</em>, as shown in the second example. Note 
that this is &lt;not&gt; <em>a^(b^c)</em>, which would be right associative. 
<P>
<P>
When 
<a href=r38_0300.html#r38_0308>nat</a> is on (the default), REDUCE output produc
es raised 
exponents, as shown. 
<P>
<P>
A square 
<a href=r38_0300.html#r38_0345>matrix</a> may also be raised to positive 
and negative powers with 
the exponentiation operator (negative powers require the matrix to be 
invertible). Scalar expressions and 
<a href=r38_0001.html#r38_0045>equation</a>s 
may be raised to fractional and floating-point powers. 
<P>
<P>
<P>

<a name=r38_0033>

<title>geqsign</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>>=</b> _ _ _ <b>GEQSIGN</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
<em>&gt;=</em> is an infix binary comparison operator, which returns true if 
its first argument is greater than or equal to its second argument. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; <em>&gt;=</em> &lt;expression&gt; 
<P>
<P>
<P>
&lt;expression&gt; must evaluate to an integer or floating-point number. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
if (3 &gt;= 2) then yes; 

  yes 


a := 15; 

  A := 15 


if a &gt;= 20 then big else small;
 

  small 

</tt></pre><p>The binary comparison operators can only be used for comparisons b
etween 
numbers or variables that evaluate to numbers. The truth values returned 
by such a comparison can only be used inside programming constructs, such 
as 
<a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> 
or 
<a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or 
<a href=r38_0200.html#r38_0228>while</a>...<em>do</em>. 
<P>
<P>
<P>

<a name=r38_0034>

<title>greater</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>></b> _ _ _ <b>GREATER</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>&gt;</em> is an infix binary comparison operator that returns 
 true if its first argument is strictly greater than its second. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; <em>&gt;</em> &lt;expression&gt; 
<P>
<P>
<P>
&lt;expression&gt; must evaluate to a number, e.g., integer, rational or 
floating point number. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
on rounded; 

if 3.0 &gt; 3 then write &quot;different&quot; else write &quot;same&quot;; 


  same 


off rounded; 

a := 20; 

  A := 20 


if a &gt; 20 then write &quot;bigger&quot; else write &quot;not bigger&quot;; 


  not bigger 

</tt></pre><p>The binary comparison operators can only be used for comparisons b
etween 
numbers or variables that evaluate to numbers. The truth values returned 
by such a comparison can only be used inside programming constructs, such 
as 
<a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> or 

<a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or 
<a href=r38_0200.html#r38_0228>while</a>...<em>do</em>. 
<P>
<P>
<P>

<a name=r38_0035>

<title>leqsign</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b><=</b> _ _ _ <b>LEQSIGN</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
<em>&lt;=</em> is an infix binary comparison operator that returns 
 true if its first argument is less than or equal to its second argument. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; <em>&lt;=</em> &lt;expression&gt; 
<P>
<P>
<P>
&lt;expression&gt; must evaluate to a number, e.g., integer, rational or 
floating point number. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
a := 10; 

  A := 10 


if a &lt;= 10 then true; 

  true

</tt></pre><p>The binary comparison operators can only be used for comparisons b
etween 
numbers or variables that evaluate to numbers. The truth values returned 
by such a comparison can only be used inside programming constructs, such 
as 
<a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> or 

<a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or 
<a href=r38_0200.html#r38_0228>while</a>...<em>do</em>. 
<P>
<P>
<P>

<a name=r38_0036>

<title>less</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b><</b> _ _ _ <b>LESS</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
<em>&lt;</em> is an infix binary logical comparison operator that 
returns true if its first argument is strictly less than its second 
argument. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;expression&gt; <em>&lt;</em> &lt;expression&gt; 
<P>
<P>
<P>
&lt;expression&gt; must evaluate to a number, e.g., integer, rational or 
floating point number. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
f := -3; 

  F := -3 


if f &lt; -3 then write &quot;yes&quot; else write &quot;no&quot;; 


  no

</tt></pre><p>The binary comparison operators can only be used for comparisons b
etween 
numbers or variables that evaluate to numbers. The truth values returned 
by such a comparison can only be used inside programming constructs, such 
as 
<a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> 
or 
<a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em> or 

<a href=r38_0200.html#r38_0228>while</a>...<em>do</em>. 
<P>
<P>
<P>

<a name=r38_0037>

<title>tilde</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>~</b> _ _ _ <b>TILDE</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>~</em> is used as a unary prefix operator in the left-hand 
sides of 
<a href=r38_0050.html#r38_0060>rule</a>s to mark 
<a href=r38_0050.html#r38_0061>free variable</a>s. A double tilde 
marks an optional 
<a href=r38_0050.html#r38_0061>free variable</a>. 
<P>
<P>

<a name=r38_0038>

<title>group</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b><<</b> _ _ _ <b>GROUP</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
The <em>&lt;&lt;</em>...<em>&gt;&gt;</em> command is a group statement, 
used to group statements 
together where REDUCE expects a single statement. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
<em>&lt;&lt;</em>&lt;statement&gt;{; &lt;statement&gt; <em>or</em> 
 &lt;statement&gt;}* <em>&gt;&gt;</em> 
<P>
<P>
<P>
&lt;statement&gt; may be any valid REDUCE statement or expression. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
a := 2; 

  A := 2 


if a &lt; 5 then &lt;&lt;b := a + 10; write b&gt;&gt;; 


  12 


&lt;&lt;d := c/15; f := d + 3; f**2&gt;&gt;;
 

   2
  C  + 90*C + 202
  ----------------
        225

</tt></pre><p>The value returned from a group statement is the value of the last
 
individual statement executed inside it. Note that when a semicolon is 
placed between the last statement and the closing brackets, 0 or 
 nil is returned. Group statements are often used in the 
consequence portions of 
<a href=r38_0050.html#r38_0052>if</a>...<em>then</em>, 

<a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em>, and 

<a href=r38_0200.html#r38_0228>while</a>...<em>do</em> 
clauses. They may also be used in interactive 
operation to execute several statements at one time. Statements inside 
the group statement are separated by semicolons or dollar signs. 
<P>
<P>
<P>
<P>

<a name=r38_0039>

<title>AND</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>AND</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>and</em> binary logical operator returns true if both of its 
arguments are true. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
&lt;logical\_expression&gt; <em>and</em> &lt;logical\_expression&gt; 
<P>
<P>
<P>
&lt;logical\_expression&gt; must evaluate to true or nil. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
a := 12; 

  A := 12 


if numberp a and a &lt; 15 then write a**2 else write &quot;no&quot;;
 


  144 


clear a; 

if numberp a and a &lt; 15 then write a**2 else write &quot;no&quot;;
 


  no

</tt></pre><p>Logical operators can only be used inside conditional statements, 
such as 

<a href=r38_0200.html#r38_0228>while</a>...<em>do</em> or 

<a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em>. <em>and
</em> examines each of 
its arguments in order, and quits, returning nil, on finding an 
argument that is not true. An error results if it is used in other 
contexts. 
<P>
<P>
<em>and</em>is left associative: <em>x and y and z</em> is equivalent to 
<em>(x and y) and z</em>. 
<P>
<P>
<P>

<a name=r38_0040>

<title>BEGIN</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>BEGIN</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
<em>begin</em> is used to start a 
<a href=r38_0001.html#r38_0041>block</a> statement, which is closed with 
<em>end</em>. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
<em>begin</em>&lt;statement&gt;{<em>;</em> &lt;statement&gt;}* <em>end</em> 
<P>
<P>
<P>
&lt;statement&gt; is any valid REDUCE statement. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
begin for i := 1:3 do write i end; 


  1
  2
  3     


begin scalar n;n:=1;b:=for i:=1:4 product(x-i);return n end;
 


  1 


b; 

   4        3        2
  X   - 10*X   + 35*X   - 50*X  + 24

</tt></pre><p>A <em>begin</em>...<em>end</em> block can do actions (such as <em>
write</em>), but 
does not 
return a value unless instructed to by a 
<a href=r38_0050.html#r38_0058>return</a> statement, which must 
be the last statement executed in the block. It is unnecessary to insert 
a semicolon before the <em>end</em>. 
<P>
<P>
Local variables, if any, are declared in the first statement immediately 
after <em>begin</em>, and may be defined as <em>scalar, integer,</em> or 
<em>real</em>. 
<a href=r38_0150.html#r38_0188>array</a> variables declared 
within a <em>begin</em>...<em>end</em> block 
are global in every case, and 
<a href=r38_0150.html#r38_0199>let</a> statements have global 
effects. A 
<a href=r38_0150.html#r38_0199>let</a> statement involving a formal parameter af
fects 
the calling parameter that corresponds to it. 
<a href=r38_0150.html#r38_0199>let</a> statements 
involving local variables make global assignments, overwriting outside 
variables by the same name or creating them if they do not exist. You 
can use this feature to affect global variables from procedures, but be 
careful that you do not do it inadvertently. 
<P>
<P>
<P>
<P>

<a name=r38_0041>

<title>block</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>BLOCK</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
A <em>block</em> is a sequence of statements enclosed by 
commands 
<a href=r38_0001.html#r38_0040>begin</a> and 
<a href=r38_0001.html#r38_0044>end</a>. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
<em>begin</em>&lt;statement&gt;{<em>;</em> &lt;statement&gt;}* <em>end</em> 
<P>
<P>
<P>
For more details see 
<a href=r38_0001.html#r38_0040>begin</a>. 
<P>
<P>

<a name=r38_0042>

<title>COMMENT</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>COMMENT</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
Beginning with the word <em>comment</em>, all text until the next statement 
terminator (<em>;</em> or <em>$</em>) is ignored. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>

x := a**2 comment--a is the velocity of the particle;;
 


        2
  X := A

</tt></pre><p>Note that the first semicolon ends the comment and the second one 

terminates the original REDUCE statement. 
<P>
<P>
Multiple-line comments are often needed in interactive files. The 
<em>comment</em> command allows a normal-looking text to accompany the 
REDUCE statements in the file. 
<P>
<P>
<P>

<a name=r38_0043>

<title>CONS</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>CONS</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>cons</em> operator adds a new element to the beginning of a 

<a href=r38_0300.html#r38_0302>list</a>. Its 
operation is identical to the symbol 
<a href=r38_0001.html#r38_0023>dot</a> (dot). It can be used 
infix or prefix. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
<em>cons</em>(&lt;item&gt;,&lt;list&gt;) or &lt;item&gt; <em>cons</em> &lt;list
&gt; 
<P>
<P>
<P>
&lt;item&gt; can be any REDUCE scalar expression, including a list; &lt;list&gt;
 
must be a list. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>

liss := cons(a,{b}); 

  {A,B} 



liss := c cons liss; 

  {C,A,B} 



newliss := for each y in liss collect cons(y,list x);
 


  NEWLISS := {{C,X},{A,X},{B,X}} 



for each y in newliss sum (first y)*(second y);
 


  X*(A + B + C)

</tt></pre><p>If you want to use <em>cons</em> to put together two elements into
 a new list, 
you must make the second one into a list with curly brackets or the <em>list
</em> 
command. You can also start with an empty list created by <em>{}</em>. 
<P>
<P>
The <em>cons</em> operator is right associative: <em>a cons b cons c</em> is val
id 
if <em>c</em> is a list; <em>b</em> need not be a list. The list produced is 
<em>{a,b,c}</em>. 
<P>
<P>
<P>
<P>

<a name=r38_0044>

<title>END</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>END</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
The command <em>end</em> has two main uses: 
<P>
<P>
 _ _ _ (i) 
as the ending of a 
<a href=r38_0001.html#r38_0040>begin</a>...<em>end</em> 
<a href=r38_0001.html#r38_0041>block</a>; and 
<P>
 _ _ _ (ii) 
to end input from a file. 
<P>
<P>
In a <em>begin</em>...<em>end</em> 
<a href=r38_0001.html#r38_0041>block</a>, there need not be a delimiter 
(<em>;</em> or <em>$</em>) before the <em>end</em>, though there must be one 
after it, or a right bracket matching an earlier left bracket. 
<P>
<P>
Files to be read into REDUCE should end with <em>end;</em>, which must be 
preceded by a semicolon (usually the last character of the previous line). 
The additional semicolon avoids problems with mistakes in the files. If 
you have suspended file operation by answering <em>n</em> to a <em>pause</em> 
command, you are still, technically speaking, ``in&quot; the file. Use 
<em>end</em> to exit the file. 
<P>
<P>
An <em>end</em> at the top level of a program is ignored. 
<P>
<P>
<P>

<a name=r38_0045>

<title>EQUATION</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>EQUATION</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>type</b><P>
<P>
 
 <P>
<P>
An <em>equation</em> is an expression where two algebraic expressions 
are connected by the (infix) operator 
<a href=r38_0100.html#r38_0110>equal</a> or by <em>=</em>. 
For access to the components of an <em>equation</em> the operators 

<a href=r38_0150.html#r38_0158>lhs</a>, 
<a href=r38_0150.html#r38_0175>rhs</a> or 
<a href=r38_0150.html#r38_0169>part</a> can be used. The 
evaluation of the left-hand side of an <em>equation</em> is controlled 
by the switch 
<a href=r38_0250.html#r38_0283>evallhseqp</a>, while the right-hand side is 
evaluated unconditionally. When an <em>equation</em> is part of a 
logical expression, e.g. in a 
<a href=r38_0050.html#r38_0052>if</a> or 
<a href=r38_0200.html#r38_0228>while</a> statement, 
the equation is evaluated by subtracting both sides can comparing 
the result with zero. 
<P>
<P>
Equations occur in many contexts, e.g. as arguments of the 
<a href=r38_0150.html#r38_0182>sub</a> 
operator and in the arguments and the results 
of the operator 
<a href=r38_0150.html#r38_0179>solve</a>. An equation can be member of a 
<a href=r38_0300.html#r38_0302>list</a> 
and you may assign an equation to a variable. Elementary arithmetic is supported
 
for equations: if 
<a href=r38_0250.html#r38_0283>evallhseqp</a> is on, you may add and subtract 
equations, and you can combine an equation with a scalar expression by 
addition, subtraction, multiplication, division and raise an equation 
to a power. 
 <P> <H3> 
examples: </H3>
<p><pre><tt>
on evallhseqp;

u:=x+y=1$

v:=2x-y=0$

2*u-v; 

  - 3*y=-2


ws/3; 

    2
  y=--
    3

</tt></pre><p><P>
<P>
Important: the equation must occur in the leftmost term of such an expression. 
For other operations, e.g. taking function values of both sides, use the 

<a href=r38_0150.html#r38_0163>map</a> operator. 
<P>
<P>

<a name=r38_0046>

<title>FIRST</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>FIRST</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
 <P>
<P>
The <em>first</em> operator returns the first element of a 
<a href=r38_0300.html#r38_0302>list</a>. 
 <P> <H3> 
syntax: </H3>
<P>
<P>
<em>first</em>(&lt;list&gt;) or <em>first</em> &lt;list&gt; 
<P>
<P>
<P>
&lt;list&gt; must be a non-empty list to avoid an error message. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
alist := {a,b,c,d}; 

  ALIST := {A,B,C,D} 


first alist; 

  A 


blist := {x,y,{ww,aa,qq},z}; 

  BLIST := {X,Y,{WW,AA,QQ},Z} 


first third blist; 

  WW

</tt></pre><p>
<a name=r38_0047>

<title>FOR</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>FOR</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
 <P>
<P>
The <em>for</em> command is used for iterative loops. There are many 
possible forms it can take. 
<P>
<P>
<p><pre><tt>
                   /                   
   /               |STEP &lt;number&gt; UNTIL|        
   |&lt;var&gt;:=&lt;number&gt;|                   |&lt;number&gt;|
FOR|               |         :         |        |&lt;action&gt; &lt;exprn&gt;
   |                                  /        |
   |EACH &lt;var&gt; IN &lt;list&gt;                        |
                                               /

 where &lt;action&gt; ::= DO|PRODUCT|SUM|COLLECT|JOIN.
</tt></pre><p>&lt;var&gt; can be any valid REDUCE identifier except <em>t</em> o
r 
<em>nil</em>, &lt;inc&gt;, &lt;start&gt; and &lt;stop&gt; can be any expression 

that evaluates to a positive or negative integer. &lt;list&gt; must be a 
valid 
<a href=r38_0300.html#r38_0302>list</a> structure. 
The action taken must be one of the actions shown 
above, each of which is followed by a single REDUCE expression, statement 
or a 
<a href=r38_0001.html#r38_0038>group</a> (<em>&lt;&lt;</em>...<em>&gt;&gt;</em>)
 or 
<a href=r38_0001.html#r38_0041>block</a> 
(
<a href=r38_0001.html#r38_0040>begin</a>...
<a href=r38_0001.html#r38_0044>end</a>) statement. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
for i := 1:10 sum i;                                    
 


  55 


for a := -2 step 3 until 6 product a;
							


  -8 


a := 3; 

  A := 3 


for iter := 4:a do write iter; 

m := 0; 

  M := 0 


for s := 10 step -1 until 3 do &lt;&lt;d := 10*s;m := m + d&gt;&gt;; 

m; 

  520 


for each x in {q,r,s} sum x**2; 

   2    2    2
  Q  + R  + S  


for i := 1:4 collect 1/i;                              
 


     1 1 1
  {1,-,-,-} 
     2 3 4


for i := 1:3 join list solve(x**2 + i*x + 1,x);         
 


        SQRT(3)*I + 1
  {{X= --------------,
              2
        SQRT(3)*I - 1
    X= --------------}
              2
   {X=-1},
         SQRT(5) + 3   SQRT(5) - 3
   {X= - -----------,X=-----------}}
              2             2

</tt></pre><p>The behavior of each of the five action words follows: 
<P>
<P>
<p><pre><tt>
                           Action Word Behavior
Keyword   Argument Type                    Action
   do    statement, command, group   Evaluates its argument once
         or block                    for each iteration of the loop,
                                     not saving results
collect expression, statement,       Evaluates its argument once for
        command, group, block, list  each iteration of the loop,
                                     storing the results in a list
                                     which is returned by the for
                                     statement when done
 join   list or an operator which    Evaluates its argument once for
        produces a list              each iteration of the loop,
                                     appending the elements in each
                                     individual result list onto the
                                     overall result list
product expression, statement,       Evaluates its argument once for
        command, group or block      each iteration of the loop,
                                     multiplying the results together
                                     and returning the overall product
  sum   expression, statement,       Evaluates its argument once for
        command, group or block      each iteration of the loop,
                                     adding the results together and
                                     returning the overall sum
</tt></pre><p>For number-driven <em>for</em> statements, if the ending limit is 
smaller 
than the beginning limit (larger in the case of negative steps) the action 
statement is not executed at all. The iterative variable is local to the 
<em>for</em> statement, and does not affect the value of an identifier with 
the same name. For list-driven <em>for</em> statements, if the list is 
empty, the action statement is not executed, but no error occurs. 
<P>
<P>
You can use nested <em>for</em> statements, with the inner <em>for</em> 
statement after the action keyword. You must make sure that your inner 
statement returns an expression that the outer statement can handle. 
<P>
<P>
<P>

<a name=r38_0048>

<title>FOREACH</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>FOREACH</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>command</b><P>
<P>
 
 <P>
<P>
<em>foreach</em>is a synonym for the <em>for each</em> variant of the 

<a href=r38_0001.html#r38_0047>for</a> construct. It is designed to iterate down
 a list, and an 
error will occur if a list is not used. The use of <em>for each</em> is 
preferred to <em>foreach</em>. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
<em>foreach</em>&lt;variable&gt; in &lt;list&gt; &lt;action&gt; &lt;expression
&gt; 
<P>
<P>
where &lt;action&gt; ::= <em>do | product | sum | collect | join</em> 
<P>
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
foreach x in {q,r,s} sum x**2; 

   2    2    2
  Q  + R  + S

</tt></pre><p>
<a name=r38_0049>

<title>GEQ</title></a>
<p align="centre"><img src="redlogo.gif" width=621 height=60 border=0 alt="REDUC
E"></p>
<b><a href=r38_idx.html>INDEX</a></b><p><p>



<b>GEQ</b> _ _ _  _ _ _  _ _ _  _ _ _ <b>operator</b><P>
<P>
 
The <em>geq</em> operator is a binary infix or prefix logical operator. It 
returns true if its first argument is greater than or equal to its second 
argument. As an infix operator it is identical with <em>&gt;=</em>. 
 <P> <H3> 
syntax: </H3>
<P>
<P>
<em>geq</em>(&lt;expression&gt;,&lt;expression&gt;) or &lt;expression&gt; 
<em>geq</em> &lt;expression&gt; 
<P>
<P>
<P>
&lt;expression&gt; can be any valid REDUCE expression that evaluates to a 
number. 
<P>
<P>
 <P> <H3> 
examples: </H3>
<p><pre><tt>
a := 20; 

  A := 20 


if geq(a,25) then write &quot;big&quot; else write &quot;small&quot;;
			 


  small 


if a geq 20 then write &quot;big&quot; else write &quot;small&quot;;
			 


  big  


if (a geq 18) then write &quot;big&quot; else write &quot;small&quot;;
			 


  big

</tt></pre><p>Logical operators can only be used in conditional statements such 
as 
<P>
<P>

<a href=r38_0050.html#r38_0052>if</a>...<em>then</em>...<em>else</em> or 

<a href=r38_0050.html#r38_0056>repeat</a>...<em>until</em>. 
<P>
<P>
<P>


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]