How do I get the list of all OwnValues of symbols in the Global` context?
All my attempts have failed because OwnValues insists taking only Symbol, and Names[] only returns a list of String:
ClearAll["Global`*"]
a = 3;
OwnValues[Evaluate[Symbol[#]]] & /@ Names["Global`*"]
OwnValues::sym : Argument 3 at position 1 expected to be a symbol
{OwnValues[3]}
Converting the String to Symbol causes the Symbol to evaluate before it enters OwnValues.
Cases[Names["Global`*"], x_ /; ToExpression[x, InputForm, OwnValues]=!={}]– Carl Woll Jul 15 '17 at 18:28Language`ExtendedDefinitionis a useful function that accepts strings and returns a list of *Values plus a few other pieces of information. – Carl Woll Jul 15 '17 at 18:32