Documentation

# forget

Clear the remember table of a procedure

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

forget(f)

## Description

forget(f) clears the remember table of a procedure f. The forget function clears only remember tables created by the option remember.

The forget function clears only remember tables created by the option remember. The function does not affect the remember tables created by prog::remember.

Do not call the forget function for predefined MuPAD® functions. Many predefined MuPAD functions have special values stored in their remember tables. The forget function does not throw an error when you call it for a predefined MuPAD function.

The forget function does not work recursively. If an inner procedure in a nested procedure uses the option remember, the forget function does not clear the remember table created for the inner procedure.

## Examples

### Example 1

If you use the option remember in a procedure, MuPAD stores all input arguments you used in the procedure calls as indices of the remember table, and the corresponding results as values of these entries. For example, create the following procedure f as a wrapper for the MuPAD sign function. Use the option remember to enable the remember mechanism for the procedure f:

f := proc(x)
option remember;
begin
sign(x)
end:

Now compute the sign function for the values -1, 0, and 1:

f(-1), f(0), f(1)

You can define a different value for sign(0). First use the unprotect function to be able to overwrite the value of sign. Then assign the new value to sign(0):

unprotect(sign):
sign(0):= 1/2:

Although you specified the new value for sign(0), MuPAD does not recalculate the result of the function call f(0). Instead, the system returns the result stored in the remember table:

f(0)

To clear a remember table created by the option remember, use the forget function:

forget(f):
f(0)

If you assign a value to a function call, calling the forget function also clears that value:

f(2) := 1/3:
f(2)

forget(f):
f(2)

For further computations, restore the sign function to its default definition. Use the protect function with the ProtectLevelError option to prevent further changes to sign. Also, delete the procedure f:

sign(0):= 0:
protect(sign, ProtectLevelError):
delete f

## Parameters

 f A procedure or function environment

## Return Values

Void object of domain type DOM_NULL