, , , . HoldPattern , , Hold , , ReleaseHold.
In[1]:= {a, b, c} = {1, 2, 3};
Unevaluated :
In[2]:= x = Thread[HoldPattern /@ Unevaluated[{a, b, c}] -> Range[3]]
Out[2]= {HoldPattern[a] -> 1, HoldPattern[b] -> 2, HoldPattern[c] -> 3}
, , . , , . , OwnValues DownValues, . HoldPattern Verbatim:
In[3]:= f[rules_] :=
Replace[rules,
HoldPattern[Verbatim[HoldPattern][s_Symbol] -> rhs_] :>
With[{string = ToString[Unevaluated[s]]},
string -> rhs], {1}]
The level specification Replaceis not there to make sure that nothing will happen if rhsit is itself a rule or a list of rules.
In[4]:= f[x]
Out[4]= {"a" -> 1, "b" -> 2, "c" -> 3}
source
share