8
$\begingroup$

I create a lot of symbols, and then I move on to my next set of manipulations. I noticed that symbols from prior sessions are still around. I have no idea how many symbols are in my context, but there must be a lot of them. How can I see what symbols I have lying around?

I see that

Names["*"] 

will give me a list of all symbols, but that includes the upper-case system symbols, which I don't want to see.

$\endgroup$
2

1 Answer 1

12
$\begingroup$

User defined symbols/functions are in the Global` context:

a = 1;
b[x_] := a x^2;
c[x_] := f[x];

Names["Global`*"]

{"a", "b", "c", "f", "x"}

$\endgroup$
2
  • 2
    $\begingroup$ I would argue that, in fact, neither f nor x are user-defined symbols in your example. I would only consider a, b, c to be. Given the accept, I guess OP would disagree with me though. $\endgroup$ Commented Jul 22, 2018 at 1:36
  • 4
    $\begingroup$ @AccidentalFourierTransform The other problem I see is that not all user-defined symbols are in the Global context. This probably suffices for many purposes but it's not really robust. $\endgroup$
    – Mr.Wizard
    Commented Jul 22, 2018 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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