Example question: I look for all the symbols with a pattern: foundVars=Names["var*"]
. I want to get all their Own, Down, and Up values and save them. I can do this with Save
but that's not quite my question. I can't do this: DownValues/@foundVars
Example Question 2: I create a function to check symbol naming:
Attributes[checkName]=HoldAll
checkName[x_]:=StringMatchQ[SymbolName[x],"var*"]
But I run into this:
in: var3=.; (*Clear var3*)
in: checkName[var3]
out: True (*so far so good*)
in: var3 = 2; (*give var3 a value*)
in: checkName[var3]
out: SymbolName: Argument 2 at position 1 is expected to be a symbol
Looking at the results from DownValues
, OwnValues
, etc. I'm guessing the trick has something to do with HoldPattern
, but I haven't been able to piece it together. Let me know some tricks and best practices when working with symbols.