问题描述
从 Mathics 开始,我尝试了:
Subscript[a,0] = 1
但它给出了错误:
Subscript[a,0] 中的标签下标受保护。
解决方法
此消息意味着您尝试执行的操作没有意义。下标是一个系统函数,可以防止无意中重新定义,就像加号 (+) 或任何其他内置系统函数一样。
根据:
https://reference.wolfram.com/language/ref/Subscript.html
下标是一个格式为 x_(y) 的对象。
您会收到与尝试相同的错误消息:
Plus[a,0] = 1
另请注意,Wolfram 语言和数学中的列表从 1 开始,而不是 0。
以下是如何创建列表变量a,其中元素在索引 1 处包含值 1:
$ mathics
Mathics 2.0.1.dev
on CPython 3.8.8 (default,Feb 27 2021,09:08:32)
using SymPy 1.7.1,mpmath 1.2.1,numpy 1.20.1,cython 0.29.22
Copyright (C) 2011-2021 The Mathics Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software,and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.
Quit by evaluating Quit[] or by pressing CONTROL-D.
In[1]:= a = {1}
Out[1]= {1}
In[2]:= a[[1]]
Out[2]= 1
也许 https://www.wolfram.com/language/fast-introduction-for-programmers/en/lists/ 和 https://www.wolfram.com/language/fast-introduction-for-programmers/en/assignments/ 是开始的好地方。