clear_variables
Remove specific variables, match patterns, or clear all Global` variables from a Mathematica kernel session.
Instructions
Clear variables from the Mathematica kernel session.
Equivalent to Python's 'del' or clearing notebook state.
Args: names: Specific variable names to clear (e.g., ["x", "y", "z"]) pattern: Wolfram pattern to match (e.g., "temp*" clears temp1, temp2, etc.) clear_all: If True, clear ALL Global` variables (use with caution!)
Returns: List of cleared variables
Example: clear_variables(names=["x", "y"]) -> {cleared: ["x", "y"], count: 2} clear_variables(pattern="temp*") -> {cleared: ["temp1", "temp2"], count: 2}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| names | No | ||
| pattern | No | ||
| clear_all | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |