Given a numerical value, is it possible to check whether that value is stored in (or defines) some variable in the notebook?
Maybe if I could list all of the defined variables, then I could simply select the one(s) that equal the value. Is this possible?
I feel it should be possible, but I don't know how to approach it. For example, whenever I set
x = 2; y = 3; z = 3;
I wonder if I can run some command such that
In[] := GetDefinedVariables[]
Out[] = {x, y, z}
or
In[] := GetDefinedVariables[]
Out[] = {{x,2}, {y,3}, {z,3}}
Ideally, I would like a function to do the following
In[] := GetCorrespondingVariables[{2,3,4}]
Out[] = {x, {y,z}, Null}
Could this also work for non-numerical variables?
?Global`*
will list everything in the Global context which will include the variables you have defined and more. If you define variables in another context you can check that also. $\endgroup$x = 2; y = 3; z = 3; {#, ToExpression@#} & /@ Names["Global`*"]
$\endgroup$