See currently assigned variables in Mathematica

401 Views Asked by At

I've noticed that in a notebook, if I define a variable, and then delete the definition, the variable stays assigned. Is there a quick way to see all the variables that are assigned? I can find them by using the debugger, but it is kind of tedious for a quick check.

1

There are 1 best solutions below

0
On

Mathematica associates with each symbol a set of values. OwnValues is the one that stores value assignments to the symbol.

This code returns the list of symbol names (as strings) for those symbols whose OwnValues is non-empty, i.e. the symbol has been assigned a value:

Select[Names["Global`*"], 
 ToExpression[#, InputForm, OwnValues] =!= {} &]