CLEAR INDEX

CLEAR _ _ _ _ _ _ _ _ _ _ _ _ command

The clear command is used to remove assignments or remove substitution rules from any expression.

syntax:

clear<identifier>{,<identifier>}+ or

<let-type statement> clear <identifier>

<identifier> can be any scalar, matrix, or array variable or procedure name. <let-type statement> can be any general or specific let statement (see below in Comments).

examples:


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

Although it is not a good idea, operators of the same name but tak ing different numbers of arguments can be defined. Using a clear statement on any of these operators clears every one with the same name, even if the number of arguments is different.

The clear command is used to ``forget" matrices, arrays, operators and scalar variables, returning their identifiers to the pristine state to be used for other purposes. When clear is applied to array elements, the contents of the array element becomes the argument for clear. Thus, you get an error message if the element contains a number, or some other expression that is not a legal argument to clear. 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 clear to set array or matrix elements to 0. You will not be pleased with the results.

If you are trying to clear power or product substitution rules made with either let or forall...let, 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 clear instead of the word let. This is shown in the last example. Any other type of let or forall...let substitution can be cleared with just the variable or operator name. match behaves the same as let in this situation. There is a more complicated exa mple under forall.