Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Possible Duplicate:
How do I clear all user defined symbols?

The normal way I reset the Mathematica kernel to its initial state is through the notebook interface: Evaluation menu, Quit Kernel item, Local submenu, then the Quit confirmer button in the resulting dialog box. I do this often enough that my fingers know the drumbeat: Alt-V Q L Q.

But I really need a way to set things back to normal from code. I suppose I could go

ClearAll /@ Names["Global`*"]

or even

Remove /@ Names["Global`*"]

which does much of what I want, but seems really ham-handed to me, and doesn't really guarantee a complete system reset -- at least I don't think.

There is also the ancient CleanSlate utility, which I can call from inside a notebook or package, but I have heard rumors that it's deprecated and unsupported:

Mathematica graphics

My attempts to search the documentation and Mathematica graphics for something resembling Reset or Restart or Clean yielded nothing useful.

Advice?

EDIT: In case you're wondering, I want this for unit-testing big Packages, where I want to Reset in the unit-testing scripts so that I can have deterministic values for results of certain Unique[] evaluations.

EDIT: I found Quit[] and Exit[]. That may be as close as we can get. I do not see any difference in them

Mathematica graphics

share|improve this question

marked as duplicate by Mr.Wizard Jun 22 '12 at 1:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
I wouldn't rely on specific numbers from Unique[]. They could very easily change from version to version. –  Brett Champion Jun 21 '12 at 20:19
    
I'm willing to update my unit tests at version-change boundaries . . . in any event, there might be other good reasons to do a reset. –  Reb.Cabin Jun 21 '12 at 20:32
1  
You (or anyone else) might find this thread about removing a loaded package from memory useful. –  István Zachar Jun 21 '12 at 20:49
    
apologies -- didn't realize it was a duplicate till we got into the answers. –  Reb.Cabin Jun 22 '12 at 17:43

1 Answer 1

up vote 7 down vote accepted

Does running Quit[] do what you want?

share|improve this answer
1  
You don't even need the []. –  Brett Champion Jun 21 '12 at 21:17
2  
@BrettChampion I've been wasting my life away! Thanks. –  ArgentoSapiens Jun 21 '12 at 21:58
    
@Brett doesn't that go against the Mathematica paradigm? Aren't nearly all other actions made with the form Action[]? This seems more like an allowance to placate users coming from other systems than good practice. –  Mr.Wizard Jun 22 '12 at 1:55
1  
@Mr.Wizard Probably. –  Brett Champion Jun 22 '12 at 2:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.