File r37/lisp/csl/html/r37_0189.html artifact 0253f183de part of check-in aacf49ddfa



<A NAME=CLEAR>

<TITLE>CLEAR</TITLE></A>
<b><a href=r37_idx.html>INDEX</a></b><p><p>



<B>CLEAR</B> _ _ _  _ _ _  _ _ _  _ _ _ <B>command</B><P>
<P>
 
The <em>clear</em> command is used to remove assignments or remove substitution 

rules from any expression. 
<P>
<P>
 <P> <H3> 
syntax: </H3>
<em>clear</em>&lt;identifier&gt;{,&lt;identifier&gt;}+ or 
<P>
<P>
&lt;let-type statement&gt; <em>clear</em> &lt;identifier&gt; 
<P>
<P>
<P>
&lt;identifier&gt; can be any <em>scalar</em>, 
<A HREF=r37_0345.html>matrix</A>, 
or 
<A HREF=r37_0188.html>array</A> variable or 

<A HREF=r37_0055.html>procedure</A> name. &lt;let-type statement&gt; can be any 
general 
or specific 
<A HREF=r37_0199.html>let</A> statement (see below in Comments). 
<P>
<P>
 <P> <H3> 
examples: </H3>
<P><PRE><TT>
array a(2,3); 

a(2,2) := 15; 

  A(2,2) := 15 


clear a; 

a(2,2); 

  Declare A operator? (Y or N) 


let x = y + z; 

sin(x); 

  SIN(Y + Z) 


clear x; 

sin(x); 

  SIN(X) 


let x**5 = 7; 

clear x; 

x**5; 

  7 


clear x**5; 

x**5; 

   5
  X

</TT></PRE><P>Although it is not a good idea, operators of the same name but tak
ing 
different numbers of arguments can be defined. Using a <em>clear</em> statement 

on any of these operators clears every one with the same name, even if the 
number of arguments is different. 
<P>
<P>
The <em>clear</em> command is used to ``forget&quot; matrices, arrays, operators
 
and scalar variables, returning their identifiers to the pristine state 
to be used for other purposes. When <em>clear</em> is applied to array 
elements, the contents of the array element becomes the argument for 
<em>clear</em>. Thus, you get an error message if the element contains a 
number, or some other expression that is not a legal argument to 
<em>clear</em>. If the element contains an identifier, it is cleared. 
When clear is applied to matrix elements, an error message is returned 
if the element evaluates to a number, otherwise there is no effect. Do 
 not try to use <em>clear</em> to set array or matrix elements to 0. 
You will not be pleased with the results. 
<P>
<P>
If you are trying to clear power or product substitution rules made with 
either 
<A HREF=r37_0199.html>let</A> or 
<A HREF=r37_0195.html>forall</A>...<em>let</em>, you must 
reproduce the rule, exactly as you typed it with the same arguments, up to 
but not including the equal sign, using the word <em>clear</em> instead of 
the word <em>let</em>. This is shown in the last example. Any other type of 
<em>let</em> or <em>forall</em>...<em>let</em> substitution can be cleared 
with just the variable or operator name. 
<A HREF=r37_0205.html>match</A> behaves the same as 

<A HREF=r37_0199.html>let</A> in this situation. There is a more complicated exa
mple under 

<A HREF=r37_0195.html>forall</A>. 
<P>
<P>
<P>
<P>


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