在回答之前的SO问题时,Mathematica 符号和语法模型 https://stackoverflow.com/questions/5439660/mathematica-notation-and-syntax-mods/5442152#5442152, 德律风根 vf14 https://stackoverflow.com/users/667867/telefunkenvf14提到他是
希望用Notations来强制MMA
将下标变量视为符号
这本质上就是这个问题的意思。
WReach https://stackoverflow.com/users/211232/wreach指出符号包 http://reference.wolfram.com/mathematica/Notation/guide/NotationPackage.html可以很简单地使用Symbolize
Needs["Notation`"];
Symbolize[ParsedBoxWrapper[SubscriptBox["_", "_"]]]
哪里(如丹尼尔的回答)不要太担心Box
上面的结构,你可以使用Notation
调色板可以更简单地输入这些内容。
检查一切是否按预期工作:
In[3]:= Subscript[a, b]//Head
a = 1
Subscript[a, b]
Out[3]= Symbol
Out[4]= 1
Out[5]= Subscript[a, b]
and
In[6]:= Subscript[b, 1] = {{1, 2}}
Subscript[b, 2] = {{3, 4}}
b = Join[Subscript[b, 1], Subscript[b, 2]]
Out[6]= {{1, 2}}
Out[7]= {{3, 4}}
Out[8]= {{1, 2}, {3, 4}}
Note: all of the above code has been copied as Input Text http://reference.wolfram.com/mathematica/guide/ClipboardOperations.html, so the typeset SubscriptBox
s have been converted to the input form Subscript
s. However, the Symbolize
works at the box level, so the tests need to be converted back to their 2d forms. To do this, select the code (or cells) and convert it to standard form http://reference.wolfram.com/mathematica/howto/ChangeTheFormOfInputAndOutput.html by using the Cell
menu or the shortcut http://reference.wolfram.com/mathematica/tutorial/KeyboardShortcutListing.html Ctrl-Shift-N
. The notebook with all the above code should look like