2

I can't describe exactly the problem I'm experiencing, but this kind of problem has a remarkable feature, that is, commands which couldn't work in the before can be executed correctly when i turn off the Mathematica and reopen it. Later, I know function "Clear[]", it can also solve this kind problem in the most occasions. But sometimes it's not very convenient to use Clear[] for multiple variables. I think this kind problem probably has something to do with the naming of variables and the life cycle and scope, and I want to ask 1. if there are some good habits to avoid such problems, and 2. whether there is a way to solve it other than restart Mathematica.

Aerterliusi
  • 353
  • 1
  • 5
  • 2
    Clear["Global\*"]will clear all symbols in theGlobal` context – Bob Hanlon Dec 28 '22 at 20:43
  • 1
    If I'm in that sort of experimental phase where I keep changing my function definitions, I'll sometimes end up adding DownValues when I intended to replace DownValues. If I realize that I may be in this cycle for awhile, I'll just put a ClearAll in front of my definitions. So, if I'm defining myFunc[...]:=..., I'll change it to ClearAll[myFunc];myFunc[...]:=.... Then, each time I make a change and re-evaluate that cell, I know I'm starting from a "clean slate". Typically I'll remove these superfluous ClearAlls when things have settled. – lericr Dec 28 '22 at 22:25
  • 1
    Welcome to the Mathematica Stack Exchange. The introductory book written by the inventor is a good learning resource. There is a fast intro for math students as well as a fast intro for programmers to choose from. In this particular case, you can include a minimal example (using Mathematica code, not an image) to get more focused replies. Thanks. – Syed Dec 29 '22 at 00:59
  • 2
    Another important thing is, one should always keep an eye on the color of the variable. If a variable is empty, it's blue, otherwise it's black. – xzczd Dec 29 '22 at 02:39

0 Answers0