Questions tagged [clear]
Clearing symbol values, removing symbols from memory and general garbage collection.
72 questions
0
votes
2
answers
113
views
Proper Way to Clear all 'Option' Variables for a Function?
I've poked around and searched a bit, but thus far have not been able to find anything that solves the following problem:
...
6
votes
1
answer
363
views
What is the difference between Clear and Remove?
I assume that there is difference between the commands Clear and Remove. But it seems to me that I am not aware of any caveats ...
3
votes
1
answer
113
views
What does this statement about "Block" mean in the official documentation?
Initial values specified for x, y, ... are evaluated before x, y,... are cleared.
It's from the Details in The reference to Block. And I can't understand it.
When are the local variables cleared and ...
2
votes
3
answers
100
views
Clearing a list of variables: Problems trying to control the order-of-evaluation [duplicate]
I am having trouble controlling the order of evaluation of mathematica expressions.
What I would really like is a general solution, in the form of a pair of functions ...
1
vote
1
answer
56
views
Reverting to the default Format definitions
Is there an easy way to clear all (user made) Format definitions?
E.g. made with
Format[s, TeXForm]:= rhs
To clarify. I don't ...
3
votes
2
answers
139
views
Different behavior of Clear in different versions of Mathematica
Consider the following code:
list1 = {1, 2, 3};
m = 17;
{list1, m} // Clear
In Mathematica 13.2, this syntax with Clear works ...
1
vote
1
answer
227
views
Mathematica builds up RAM usage (how to free memory)
I've already checked this post How to clear up RAM without exiting kernel?
But the longer my code works, it builds up RAM and cannot clear it. I've stopped the evaluation and done the following.
...
1
vote
1
answer
46
views
How to clear all definitions/symbols declared in all sections with the given tag?
Consider a list of chapters/sections etc. that have the same tag, say, "evaluation". Could you please tell me how to clear all the functions/symbols/definitions etc. that have been defined ...
0
votes
3
answers
122
views
Conflicting variables
So, I read a set of variables and respective values from a file and store them in a variable
specs = {{"Type", "KP", "fp"}, {"LP1", 2, 2000}, {"Type", ...
1
vote
0
answers
43
views
Sorting stored variables in memory
Given the list of stored variables
Names@"`*"
is it possible to sort them by size in used memory?
0
votes
1
answer
128
views
How to clear a function with subscript?
How to clear a function like
Subscript[f, n_][x_] := x f[x - 1] + n;
ClearAll[f] didn't work.
3
votes
2
answers
541
views
What is the difference between Clear and ClearAll? [duplicate]
I'm reading Mathematica Programming by Leonid Shifrin. And it said
ClearAll serves to clear all definitions (including attributes) for a given symbol (or symbols), ...
0
votes
0
answers
37
views
How can I prevent functions and variables from being automatically cleared when I close Mathematica? [duplicate]
The following happens with every notebook I make:
I define functions and variables.
When I quit Mathematica and reopen the notebook, all of those definitions have been cleared. The functions and ...
3
votes
1
answer
102
views
How does one clear the value of a subs variable? [closed]
I saw the topics here, but it's not clear at all how to clear variables with sub.
Ideas?
Btw, does anybody know why Mathematica won't give me the numerical value of the 4-th zeta function derivative ...
1
vote
1
answer
54
views
How to clear a selection of definitions from UpValues?
I'm trying to set up a bunch of 2D points using UpSet that I am going to use later for building lines and graphs.
...
0
votes
1
answer
357
views
How to clear this variable [duplicate]
I can not clear this variable.
How to clear?
1
vote
2
answers
81
views
ClearAll required twice on a symbol with SyntaxInformation
SyntaxInformation[f] = {"ArgumentsPattern" -> {}};
f[] := 0;
After one ClearAll[f] or ...
1
vote
1
answer
329
views
How to Unprotect and Clear the E constant?
By default, E is used to represent the Euler's number in Mathematica.
I need the variable E to behave just like other undefined variables in my code. When I run the commands
...
0
votes
1
answer
67
views
All definitions are cleared when I reopen my file [duplicate]
I just started getting into mathematica and have the problem that whenever I save and reopen my .nb file, all functions and variables are cleared and I need to shift+enter every cell again to continue ...
1
vote
2
answers
197
views
'Do' loop acting on a global variable
I need a code that will allow me to alter a matrix (a global variable) iteratively using a function update (which depends on ...
0
votes
0
answers
139
views
Question about Clear function
I have a script starting with Clear ["r*", "data*", "file*"]. Does this clear all variables starting with "r" or "data"or "file"? Also, I ...
1
vote
1
answer
220
views
Setting a function equal to another function then Clearing the latter
I have a loop in which several values of a function are computed, depending on the values for that function that were computed in the previous iteration of the loop. This could be implemented ...
11
votes
1
answer
288
views
How to clear all definitions matching f[1, ...] but not f[2, ...]?
I would like to clear all definitions of the form f[1,...] in such a way that f[2,...] remain unaffected.
The two methods I know ...
7
votes
1
answer
152
views
Clearing ::usage message
After having assigned the usage message to f using
ClearAll@f;
f::usage=ToString@RandomInteger@{10^10,10^11};
the ...
1
vote
1
answer
391
views
How to clear all variables? [closed]
I have noticed that the old trick of using:
ClearAll["Global`*"]
does not appear to work anymore. It does not clear the values of any of my variables. I assume ...
4
votes
4
answers
220
views
Is it possible to create lookups on temporary symbols that still allow the symbols to be automatically removed?
Is there some way to create lookups keyed on Temporary symbols that somehow avoid the referencing of the Temporary symbols, ...
1
vote
0
answers
290
views
How to clear all subscripted variables? [duplicate]
I have the following variable:
Subscript[n, 0 ] = 12 (\[Sigma] L^2)/(e h^2)
If I now do:
ClearAll["Global`*"]
And then ...
33
votes
5
answers
2k
views
Different strategies to get a clean Kernel. Quit, Exit, ClearAll, Remove, CleanSlate?
Often new users face problems with lingering definitions that, if unaware, may cause unexpected and frustrating behaviour.
There are several answers that illustrate different aspects of the solution, ...
2
votes
2
answers
835
views
Clear variables inside Module
I have a function that uses Module. The function takes as input a .csv that can have as many columns as it wishes to, and it ...
4
votes
1
answer
108
views
ThrowAway Environment and Scoping
I want to be able to Get a .wl file. Run some functions (who will do their job working on some separate files that are being written away). And then return to some clean slate so that I can repeat ...
-1
votes
1
answer
355
views
meaning of variable equal dot [closed]
I came across a program which I have written in a simplified form.
For[i=1,i<100, i=i+1;
func = a x^i;
func=.
];
What is purpose of "func=."?
0
votes
2
answers
274
views
How to 'unassign' variables used for PlotPoints, which subsequently print as e.g. Charting`Private`pvar$727158
I have a table of four insoluble equations, fceq, in terms of unassigned variables,
Subscript[fc, i], Subscript[μ, i].
I am using contour plots to visualise ...
10
votes
1
answer
109
views
Why ClearAll[n] does not clear effect of NumericQ[n]=True
To solve some PDE, I have to set NumericQ[n]=True on some symbol to get a solution, else Mathematica will not solve it.
When I tried ...
5
votes
3
answers
145
views
Apply Clear puzzle
This is OK
foo=1; bar=2;
Clear[foo,bar]
But this is not
foo=1; bar=2;
Clear@@{foo,bar}
Clear::ssym: 1 is not a symbol.
...
1
vote
0
answers
47
views
Is ClearAttributes built-in functon work in current cell only?
I have a question. Is ClearAttributes the built-in functon work in current cell only? This is my code:
In first cell:
Set[a, 6]
In second cell:
...
5
votes
1
answer
240
views
Clear a symbol from the kernel
I have a code that works over lists like
S0; (*initial list*)
S1=f[S0];
S2=g[S1];
S3=f[S2];
S4=f[S3];
.
.
.
where f and ...
1
vote
1
answer
272
views
Is it possible to Clear all variables defined in a given cell?
Suppose I defined a number of variables in a cell, in the Notebook interface. I know the number of this cell (In[296], for example). Is there a way to clear all the ...
3
votes
2
answers
80
views
ClearAll except a data table
How can I ClearAll variables and tables, except a table of data? Suppose the data table is WRR.
...
2
votes
2
answers
132
views
clear value from a bunch of symbols
I have a bunch of symbols which are collected as a list inside a variable within a bit of code e.g.
a=1;b=2;
par={a,b};
I want to clear the values of both ...
36
votes
2
answers
1k
views
How do I disable the stack tracing feature in Mathematica 11?
Bug was introduced in 11.0 and persisting through 11.1
It looks like the Mathematica 11 stack tracing feature (see red ellipsis in front of any warning message) prevents the garbage collector from ...
0
votes
0
answers
96
views
Calling Clear within a function [duplicate]
I want to create a function that when it is called clears the value of a parameter.
For example I want to keep the value of a parameter and then clear its valueby calling a function:
...
31
votes
3
answers
843
views
Why does removing a function and defining it on the same line not work?
Why do the two pieces of code below yield rather different results? The only difference is that in the first one the function definition is in the same line as the ...
4
votes
1
answer
669
views
How to "clear" the downvalues of a subscripted variable?
I have a function that sets certain subscripts of the symbol aa as in the following example:
...
0
votes
0
answers
59
views
Deleting variable assignments in a sub-notebook which is called from my main notebook
I have two notebooks; one main notebook which calls another notebook several times in a loop. I want to delete the assignments of variables in the sub-notebook which is called from the main one.
...
14
votes
2
answers
805
views
Good clearing practices
I have been using Mathematica for about 2 years and I'm pretty ok to write and optimize my code. Wanting to improve my practice, I often look at code examples. However, I can not determine if there is ...
16
votes
2
answers
420
views
Global context seems to be shared between kernels when using Clear?
I am trying to understand the following behaviour, and determine if it's a bug in Mathematica 10. I am using Mathematica 10.3, and can't reproduce this behaviour under Mathematica 9. The test outlined ...
4
votes
1
answer
444
views
Error given by the Clear function
I'm trying to clear out some variables that I've previously used, so that I can use them again. I tried this in a different notebook and it worked, however, now, a command like :
...
3
votes
0
answers
50
views
Context is not clearable and does not reload [closed]
I'm just going crazy with Mathematica Contexts as they absolute do not work as intended.
Simple Example:
Begin["TEST`"]
Hello[s_]:=s
Bye[s_]:=s
End[]
Now using ...
13
votes
2
answers
32k
views
How to clear everything in Mathematica? [duplicate]
I am a new user. According to a documentation,
Clear["context`*"] clears all symbols in a particular context.
I want to clear everything (functions, variables, etc..)
After I use the above command, ...
2
votes
2
answers
204
views
Partial reload of definitions from package
In order to keep my code modular, I have defined some functions in "Foo.wl" file, which I source with Needs["Foo`"].
When I modify a single function in Foo, I quit ...